I have a homemade toolbar control that is used in several places, both in an UpdatePanel and outside of one. It relies on some jQuery to set up its buttons. It has its own startup script embedded in its assembly.
What I'm having trouble with is getting the startup script to run at the right time when the toolbar is in the update panel. Since it's declared in a hidden panel in the update panel's markup, it gets created and loaded when the update panel is created. But it doesn't actually get rendered until the user has done a couple of things and the hidden panel is made visible.
What I would like is for the startup script to run every time the update panel refreshes. (Ideally I'd like it to only do that if the toolbar is visible, but I'll take "every refresh" if I have to.) But I want the toolbar to still function when outside an update panel, when all it needs to do is hook into the document's .ready() handler.
Given that the toolbar can't tell (as far as I know) from the server side whether it's inside an update panel or not, but is responsible for ensuring the necessary javascript, how can I make this happen?
Thanks.
ETA: I found an answer in the answer to this question. This works for my toolbar whether it's in the update panel or outside of one. Thanks, everybody!
Correct me if I'm wrong but I would think that the jQuery toolbar within the UpdatePanel should be executed everytime that the updatepanel is updated. So maybe on the server side you can tell whether it's a asyncpostback. If it is then you can use write some javascript within the update panel that will be executed. You might use a literalcontrol that you load into a placeholder within the update panel. Something like...
public void WebForm1_OnLoad(Object sender, EventArgs args){
if(ScriptManager.GetCurrent(Page).IsInAsyncPostBack){
var con = new LiteralControl("INSERT javascript here that would call jquery method");
this.placeHolder.Controls.Add(con);
}
}