Ajax toolkit-modelpopupextender

Source: Internet
Author: User
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?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.