This is a problem i’ve tried so solve before but gived up.
Basicly i’m using ModalPopupExtenders (from AJAX.NET) to display Panels with a few content (text, controls, etc). And i’m calling it from codebehind. And it works well.
But now i want to replace the ModalPopup with some jQuery dialog box. The problem is calling it from codebehind.
As far as i know, i have to register the jQuery libraries on RegisterStartup event, but i’ve tried it and call the jQuery from codebehind but with no sucess.
Can someone help me? I really want to replace the ModalPopup, they gives me to much trouble.
Thanks in advance.
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, GetType(), "registerDialog",
"$(function() { $('#dialog').dialog({autoOpen:false, show:'blind'}); });", true);
}
protected void Button1_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, GetType(), "openDialog",
"$('#dialog').dialog('open');", true);
}
Is this the correct way? I’ve to register it first to stay hidden.
Thanksю
If you’re using a ScriptManager, use
RegisterStartupScript(), like this:If you’re not using a ScriptManager/UpdatePanels, use the equivalent
ClientScriptManagerversion.It’s important to remember to wrap your code in a
document.readyhandler (IE has the most issues without it), so your elements (in my example,id="dialog") are in the DOM and ready.