c# - How to load javascript function from an dynamicall added control? -
The master page got a script manager.
Then I got a control with ScriptManagerProxy and UpdatePanel.
There I need to add a control dynamically (there is also a ScriptManagerProxy) inside the UpdatePanel and with that control I need to run some javascript code.
DynamicControl.ascx: DynamicControl.ascx.cs: My problem is that "doSomething ()" function is never called and I do not know why: s edit: it is called , But when I add control, I am not directly. If I code like this, then there will be an alert window: OK I think I need to add some more information: The control has been added to a dynamical which can be used in the jQuery dialog Is inside And I came to know that after the shutdown, JavaLoad is executed for the first time and then opens the dialogue. Any type of event is triggered so that the code is executed, I think. Is it possible to stress this incident? Can the script be directly executed when the control is added? Does this C # code immediately execute the Javascript tag? Please try something like this Where UpdatePanel1 is your UpdatePanel & lt; Script type = "text / javascript" & gt; Function doSomething () {warning (1); } & Lt; / Script & gt;
Public Zero Page_load (Object Sender, EventArgs e) {... ScriptManager.RegisterStartupScript (this.page, this Gettype (), "script id", "& lt; script type = 'text / javascript' & gt; doSomething (); & lt; / script & gt;" false);
"script" = type 'text / javascript' & gt; alert (1) ; & Lt; / scripts & gt;
placeHolder.Controls.Add (dynamicReportControl);
ScriptManager.RegisterStartupScript ( This.UpdatePanel1, this.UpdatePanel1.GetType (), "scriptID", "script type = 'text / javascript' & gt; DoSomething (); & lt; / script & gt;" false);
Comments
Post a Comment