开发者

append script text into the end of an asp.net web form page from user control

开发者 https://www.devze.com 2023-03-20 02:45 出处:网络
here is what I am doing from user control code behind; 开发者_Go百科ScriptManager.RegisterStartupScript(this.Page, typeof(Page),

here is what I am doing from user control code behind;

开发者_Go百科    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), 
   "JQuerySearchReminder",
    string.Format("(function() {{ $(function(){{ $('#{0}').val('{1}'); }}); }})();", ddlDestinationTrf.ClientID, srchrmdr["_did"]), 
    true);

the script code works fine, nothing wrong there. On the user control I am also using AjaxControlToolkit's CascadingDropDown control.

So the problem is that;

this c# code I am using to append the script into page is registered before the CascadingDropDown control's script code. this isn't work in this situation Because the dorpdownlist is empty if CascadingDropDown control hasn't done the job.

So guys, let me escape from this lame situation.


Have you tried setting ScriptManager.LoadScriptsBeforeUI to false. See here for details.

Alternatively, couldn't you use jquery's document.ready function to run your javascript code after the document was loaded?

0

精彩评论

暂无评论...
验证码 换一张
取 消