views:

225

answers:

1

I have an update panel load a user control, and the goal here is to have a specific JavaScript function called when this occurred. I was thinking this would be done through the Script Manager, though this does not need to be the case if there's an html alternative.

The flow is basically the following:

  • User clicks button
  • Update panel loads control
  • Javascript function is called

Many thanks

I've already tried RegisterStartupScript(..), though i may have made a syntactical mistake

if (show)
{ 
    string scriptId = String.Format("{0}:script", ++uniquePopupId);
    string scriptTag = String.Format("showPopup({0},{1});", Width, Height);
    ScriptManager.RegisterStartupScript(this, this.GetType(), scriptId, scriptTag, true);
}

Solution:

if (show)
{ 
    string scriptId = String.Format("{0}:script", ++uniquePopupId);
    string scriptTag = String.Format("showPopup({0},{1});", Width, Height);
    ScriptManager.RegisterStartupScript(updPanelChildControl, updPanelChildControl.GetType(), scriptId, scriptTag, true);
}
+2  A: 

Use

ScriptManager.RegisterStartupScript(myControlInstance, 
                                    typeof(MyControl),
                                     "key",
                                     "my javscript string here", 
                                     true);

Documentation here.

womp
I've tried something similiar to this already unless you see something wrong with what i've done.
Highstead
Ahh, i'd been using RegisterStartupScript wrong, thanks for the documentation.
Highstead