Directory:
About the modelpopupextender application (Open modalpopup dialog on page load)
How modelpopupextender triggers server events
1. There are modelpopupextender applications
<Form ID = "form1" runat = "server">
<Ajaxtoolkit: toolkitscriptmanager runat = "server" id = "toolkitscriptmanager"/>
<Div>
<Ajaxtoolkit: modalpopupextender id = "modalpopupextender1" behaviorid = "mdlpopup" runat = "server"
Targetcontrolid = "btnno" popupcontrolid = "pnlpopup" okcontrolid = "btnyes" backgroundcssclass = "modalbackground"/>
<Asp: Panel id = "pnlpopup" runat = "server" cssclass = "confirm-dialog" style = "display: none;">
<Div class = "inner">
<H2>
Show wow! </H2>
<Div class = "base">
<Asp: button id = "btnyes" runat = "server" text = "yes"/>
<Asp: button id = "btnno" runat = "server" text = "no" onclientclick = "$ find ('mdlpopup'). Hide (); Return false;"/>
<Asp: linkbutton id = "linkbutton1" runat = "server" cssclass = "close" onclientclick = "$ find ('mdlpopup'). Hide (); Return false;"/>
</Div>
</Div>
</ASP: Panel>
</Div>
</Form>
<SCRIPT type = "text/JavaScript">
// Page_load invoke
SYS. application. add_load (function ()
{
$ Find ('mdlpopup'). Show ();
});
</SCRIPT>
:
Related question address:
About using ajaxtoolkit
2. About how modelpopupextender triggers server events
When you trigger a server event, you can see it at a Glance. It's easy to directly write the event. Why do you need to write this here? That's because when I used Ajax and developed it, I found that as long as the targetcontrolid in modelpopupextender is associated with the ID of the "modify" button, then. Then, when running the interface, clicking the "modify" button will not trigger the onclick event of the button.
<Asp: button id = "btnfixtheme" runat = "server" text = "modify" onclick = "btnfixtheme_click"/>
<Ajaxtoolkit: principal id = "principal" behaviorid = "mdlpopup" runat = "server" targetcontrolid = "btnfixtheme" popupcontrolid = "pnlpopup" drag = "true" Principal = "modalbackground"/>
Why?
A: That's because the Ajax Server Control render has a code with asynchronous communication function, and does not change any code at the button that triggers this event, or the original _ dopostback ('', '') Sending method. Ajax core part will host this _ dopostback. For Ajax Control Toolkit, a piece of code is executed when the whole client page is initialized, and then the code triggered is dynamically added to the bound control. Therefore, you cannot see any changes in the event triggered by a linkbutton.
Solution code:
Protected void page_load (Object sender, eventargs E)
{
Btnfixtheme. onclientclick = "_ dopostback ('" + this. btnfixtheme. uniqueid + "','')";
}
Also: Appendix 1
How to dynamically Add a trigger to updatepanel?