Friday, September 12, 2014

Ajax Control toolkit ModalPopUp in ASP.NET C#

Here I am going to show how to create a modal pop up using AJAX control toolkit in ASP.NET and C#. Before I have show how to create a pop up using JQuery and CSS, but now its pure asp. For this you need to add AJAX Control toolkit into your project. You can download as per your version of .NET (3.5,4.0,4.5).
After downloading create a project and add the reference of the AJAX Control Toolkit into your project.

Now your visual studio is ready to begin with AJAX Control Toolkit. Add a new Web Form. In the tool Box you will get the control ModalPopupExtender within AJAX Control Toolkit.

Lets first see how to set a ModalPopup to show any message. Check the following code.


AJAX Modal Popup

Here is the content which you wan to show

Run this example and on the button click you will get a pop up showing in your browser.

Lets move to an example where you will get an message showing with data from back end. Add another page and check following code.


In the CS page write down the following code.
protected void btnClick_Click(object sender, EventArgs e)
{
 /* get data from DB */
 lblusername.Text = TextBox1.Text;
 this.ModalPopupExtender1.Show();
}

Output :
Direct Message showing

Message from code behind


I hope its clear how to create popup and how to show message or show message from code behind. For further download the full source code here.

0 comments:

Post a Comment

Follow by Email

Popular Posts

Pageviews