How can I wire jQuery on a control that isn't rendered yet on the page? I tried overriding the following methods, but they didn't work as StepNavigationTemplateContainerID html markup is not yet available on this events: Render, OnLoad, OnInit, etc
Could it be because I'm using UpdatePanel? What method/event I could override when I'm using UpdatePanel so I can issue jQuery hooks there?
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
HookNextButton();
}
void HookNextButton()
{
string nextButtonClientId = wizardCooking.FindControl("StepNavigationTemplateContainerID").FindControl("btnNextStep").ClientID + "_lnkButton";
var scriptKey = "Yo";
string theScript =
string.Format(
@"
$(function() {{
$('#{0}').click(function() {{
alert('hi');
}});
}});
", nextButtonClientId);
Type cstype = this.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, scriptKey))
{
ScriptManager.RegisterStartupScript(
this, this.GetType(), scriptKey, theScript, true);
}
}