Click here to Skip to main content
15,885,537 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: webservice Pin
farokhian6-Sep-09 21:00
farokhian6-Sep-09 21:00 
GeneralRe: webservice Pin
Abhishek Sur6-Sep-09 22:00
professionalAbhishek Sur6-Sep-09 22:00 
GeneralRe: webservice [modified] Pin
farokhian6-Sep-09 23:54
farokhian6-Sep-09 23:54 
AnswerRe: webservice Pin
Christian Graus6-Sep-09 12:19
protectorChristian Graus6-Sep-09 12:19 
QuestionUserControl and javascript. Pin
Matt Cavanagh6-Sep-09 8:05
Matt Cavanagh6-Sep-09 8:05 
AnswerRe: UserControl and javascript. Pin
Abhishek Sur6-Sep-09 10:55
professionalAbhishek Sur6-Sep-09 10:55 
GeneralRe: UserControl and javascript. Pin
Matt Cavanagh6-Sep-09 11:24
Matt Cavanagh6-Sep-09 11:24 
GeneralRe: UserControl and javascript. Pin
Abhishek Sur6-Sep-09 12:12
professionalAbhishek Sur6-Sep-09 12:12 
Well,

Just use this :

function sethtml(div,content) 
{ 
    var search = content; 
    var script; 
          
    while( script = search.match(/(<script[^>]+javascript[^>]+>\s*(<!--)?)/i)) 
    { 
      search = search.substr(search.indexOf(RegExp.$1) + RegExp.$1.length); 
       
      if (!(endscript = search.match(/((-->)?\s*<\/script>)/))) break; 
       
      block = search.substr(0, search.indexOf(RegExp.$1)); 
      search = search.substring(block.length + RegExp.$1.length); 
       
      var oScript = document.createElement('script'); 
      oScript.text = block; 
      document.appendChild(oScript); 
    } 
    var container = document.getElementById(div);
    if(!!container)
    {
       while(container.firstChild)
         container.removeChild(container.firstChild);
      container.innerHTML = content; 
    }
}


Now once you receive the response, instead of directly setting the content to the innerHTML, pass it to this function:

say the id of the div is dvResponse, then

setHtml('dvResponse', ajaxResponse);
The function will find each script blocks using RegEx pattern and add them at the end of the page. If you want the script in head sectionn, just replace the line
document.appendChild(oScript); with document.getElementsByTagName("head").item(0).appendChild(oScript);

roguemat wrote:
Also, if I did decide to have external js files then how would i include those? Because surely when i sent through the tag to include it it would be stripped out too when setting innerHTML?
</blockquote>

Yes.. you are right.. In that case you need to add the scripts on the original page where the container div is.Cool | :cool: Cool | :cool:

<div class="ForumSig"><font color="red" size="2" face="Verdana">Abhishek Sur
</font><hr><b>My Latest Articles</b><font color="#0000ff" size="1" face="Verdana">
<strong><a href="KB/database/ClrStoredProcedure.aspx">Create CLR objects in SQL Server 2005</a>
<a href="Articles/38695/UnCommon-Csharp-keywords-A-Look.aspx">C# Uncommon Keywords</a>
<a href="KB/miscctrl/Excel_data_access.aspx">Read/Write Excel using OleDB</a><p></p></strong><b><small>Don't forget to click "Good Answer" if you like to.</small></b></font>

GeneralRe: UserControl and javascript. Pin
Matt Cavanagh6-Sep-09 19:53
Matt Cavanagh6-Sep-09 19:53 
GeneralRe: UserControl and javascript. Pin
Abhishek Sur6-Sep-09 22:14
professionalAbhishek Sur6-Sep-09 22:14 
GeneralRe: UserControl and javascript. Pin
Matt Cavanagh6-Sep-09 23:09
Matt Cavanagh6-Sep-09 23:09 
AnswerRe: UserControl and javascript. Pin
Abhishek Sur8-Sep-09 13:44
professionalAbhishek Sur8-Sep-09 13:44 
Questionframes in asp.net Pin
myinstincts6-Sep-09 6:37
myinstincts6-Sep-09 6:37 
AnswerRe: frames in asp.net Pin
Manas Bhardwaj6-Sep-09 8:48
professionalManas Bhardwaj6-Sep-09 8:48 
AnswerRe: frames in asp.net Pin
Abhishek Sur6-Sep-09 10:37
professionalAbhishek Sur6-Sep-09 10:37 
Questiondatalist bound to a multiline textbox problem! [modified] Pin
Seraph_summer6-Sep-09 3:52
Seraph_summer6-Sep-09 3:52 
AnswerRe: datalist bound to a multiline textbox problem! Pin
Abhijit Jana6-Sep-09 4:12
professionalAbhijit Jana6-Sep-09 4:12 
GeneralRe: datalist bound to a multiline textbox problem! Pin
Seraph_summer6-Sep-09 4:28
Seraph_summer6-Sep-09 4:28 
QuestionRegular Expression Validator...... Pin
greendragons6-Sep-09 1:41
greendragons6-Sep-09 1:41 
AnswerRe: Regular Expression Validator...... Pin
Abhijit Jana6-Sep-09 2:20
professionalAbhijit Jana6-Sep-09 2:20 
AnswerRe: Regular Expression Validator...... Pin
N a v a n e e t h6-Sep-09 3:20
N a v a n e e t h6-Sep-09 3:20 
AnswerRe: Regular Expression Validator...... Pin
Abhishek Sur6-Sep-09 9:59
professionalAbhishek Sur6-Sep-09 9:59 
Questionabout the use of validator control in asp.net Pin
Seraph_summer5-Sep-09 23:30
Seraph_summer5-Sep-09 23:30 
AnswerRe: about the use of validator control in asp.net Pin
Abhijit Jana5-Sep-09 23:57
professionalAbhijit Jana5-Sep-09 23:57 
AnswerRe: about the use of validator control in asp.net Pin
en.Mahdi6-Sep-09 0:20
en.Mahdi6-Sep-09 0:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.