Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I create a ModalPopup programmatically?

1
Posted

How do I create a ModalPopup programmatically?

0

There are two ways to create it programmatically, on server side and on client side. Server side To create it on server side, we need to create an instance of ModalPopupExtender class, add it to the page, and set its properties accordingly. Below is the relevant code snippet: protected void Page_Load(object sender, EventArgs e) { ModalPopupExtender mpe = new ModalPopupExtender(); Page.Form.Controls.Add(mpe); mpe.TargetControlID = “button1”; mpe.PopupControlID = “popup”; } Client side It’s also possible to create it with below javascript: $create(AjaxControlToolkit.ModalPopupBehavior, {“OkControlID”:”Button2″, “PopupControlID”:”Panel1″, “PopupDragHandleControlID”:”Panel2″, “”id”:”mpe”}, null, null, $get(“Button1”)); As a matter of fact, we can find out the code above by viewing the source of the generated page. Generally, these two approaches can be applied to most of extender controls.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123