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?
精彩评论