Click here to Skip to main content
Click here to Skip to main content

Popup Control for ASP.NET

, 25 Oct 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Easiest way to implement popup window in ASP.NET

Introduction

This tip demonstrates how to implement a movable Popup window in ASP.NET. A very important feature of this control is that it can be used on most of the current browsers. It has been tested with the latest version of Mozilla, Internet Explorer, and Opera.

Background

Most of the time, developers face the problem in popup windows to automatically a hide popup window after a post back event because they use AJAX controls. In this tip, I provide you with an easy way to implement a popup window in ASP.NET without writing too much code.

Implementation

On Page design

There is very little coding necessary to implement a popup control. First, you need to add DDL in your project. And register assembly in your page by using the following code:

<%@ Register Assembly="ASP.Web.UI.PopupControl" 
    Namespace="ASP.Web.UI.PopupControl"
    TagPrefix="ASPP" %>  

After that, declare the control in the Page design (.Aspx). Whatever you want to show as popup, put into the PopupWindow tag in the following way:

<ASPP:PopupPanel HeaderText="This is Header" ID="pup" 
          runat="server" OnCloseWindowClick="MycloseWindow">
    <PopupWindow runat="server">
        <ASPP:PopupWindow ID="PopupWindow1" 
        Visible="false" runat="server">
            <asp:Label ID="lbl" runat="server">ssssssssss</asp:Label>
            <br />
            <asp:TextBox ID="txt" AutoPostBack="true" 
            runat="server"></asp:TextBox>
        </ASPP:PopupWindow>
        <ASPP:PopupWindow ID="PopupWindow2" runat="server">
            <div align="center" style="width: 500px; height: 300px">
                <asp:Label ID="Label1" runat="server">nnnnn</asp:Label>
                <br />
                <asp:TextBox ID="TextBox1" AutoPostBack="true" 
                runat="server"></asp:TextBox>
                <asp:Button ID="in" runat="server" Text="sss" />
                <asp:TextBox ID="TextBox2" AutoPostBack="true" 
                runat="server"></asp:TextBox>
            </div>
        </ASPP:PopupWindow>
    </PopupWindow>
</ASPP:PopupPanel>

On code behind

For showing purposes, use:

protected void Button1_Click(object sender, EventArgs e)
{
    pup.ShowPopupWindow();
}

For hiding purposes, use:

protected void Button2_Click(object sender, EventArgs e)
{
    pup.HidePopupWindow();
}

Events

After closing, window click event is generated if you assign to OnCloseWindowClick in popup control:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Nikhil Awatade
Software Developer (Senior)
United States United States
No Biography provided

Comments and Discussions

 
QuestionHave to click button twice to fire Pinprofessional4Dinand223-Mar-15 9:37 
QuestionMicrosoft JScript runtime error: 'tzdragg' is undefined PinmemberMember 1085666319-Mar-15 23:26 
QuestionFull DLL PinmemberJing Go Bell24-Feb-15 5:12 
QuestionFull DLL PinmemberMember 1092373613-Feb-15 1:23 
QuestionPopupPanel1An unhandled exception has occurred. Object reference not set to an instance of an object. PinmemberMember 1074388811-Feb-15 1:59 
GeneralMy vote of 1 PinprofessionalMember 1047279112-Jan-15 10:30 
QuestionFull dll PinmemberChristian Inostroza6-Jan-15 7:57 
Questiondll fail PinmemberMember 105026324-Jan-15 10:14 
AnswerDLL is attached to the article Pinmembersaquib79212-Jan-15 13:06 
QuestionDLL PinmemberMember 112969368-Dec-14 23:22 
QuestionDll Expired PinmemberUltraviolet897-Dec-14 0:11 
QuestionDll Expired PinmemberMember 1120460624-Nov-14 3:06 
GeneralMy vote of 1 Pinmemberlllyxer5-Nov-14 7:19 
Questioncan send me the dll Pinmemberjojoba202-Oct-14 23:50 
QuestionPlease send me the full DLL Pinmemberanil sojitra17-Sep-14 1:10 
Questionbrowser compatibility Pinmemberthiyajan15-Sep-14 0:26 
GeneralCan you send me dll code or unlimited dll PinmemberPrasadbaggam3-Sep-14 0:37 
GeneralRe: Can you send me dll code or unlimited dll Pinmemberanil sojitra17-Sep-14 1:04 
QuestionFull dll code/dll PinmemberMember 110499201-Sep-14 0:05 
AnswerRe: Full dll code/dll Pinmemberanil sojitra17-Sep-14 1:05 
GeneralMy vote of 1 PinmemberMember 1087813328-Aug-14 10:19 
QuestionHow to get code for DLL PinmemberMember 1087813328-Aug-14 10:01 
QuestionNice Control Can you sen DLL Pinmembergnomathibus19-Aug-14 2:01 
AnswerRe: Nice Control Can you sen DLL PinmemberMember 936965120-Aug-14 7:01 
Generalsuperb PinmemberMember 1097739728-Jul-14 21:03 
Questionproblem occur in popup PinmemberSuraj Shresth24-Jul-14 22:52 
Questioncomplete,unlimited dll Pinmembertereena21-Jul-14 21:58 
QuestionIt is work for me PinmemberAnu.v19-Jul-14 3:02 
Questiondll unlimited PinmemberMember 1094255412-Jul-14 23:15 
QuestionHas anyone ever gotten this from this guy? PinmemberSeanEckenrod5-Jun-14 7:20 
AnswerRe: Has anyone ever gotten this from this guy? PinmemberMember 108746938-Jul-14 2:06 
QuestionExpired !! PinmemberMember 108652884-Jun-14 22:26 
AnswerRe: Expired !! PinmemberMember 108746938-Jul-14 2:09 
GeneralRe: Expired !! Pinmemberppfepf18-Sep-14 1:36 
QuestionNeed DLL Please PinmemberMember 93271632-Jun-14 14:29 
QuestionDLL Question [modified] PinmemberSeanEckenrod22-May-14 6:06 
QuestionNEED DLL PinmemberMember 107928153-May-14 16:39 
QuestionDLL full PinmemberMember 974365128-Apr-14 23:24 
QuestionNeed to change the Header color PinmemberNuthan Gowda24-Apr-14 3:03 
Questiondll needed urgently Pinmemberdeepak23089015-Apr-14 19:03 
QuestionNeed dll Pinmembersree_jisha9-Apr-14 18:15 
QuestionExpired Pinmemberkreattor20-Mar-14 9:14 
Questionresolved :) PinmemberJasRaj Bishnoi10-Mar-14 21:44 
QuestionExpired PinmemberMember 1065741410-Mar-14 0:51 
QuestionNeed DLL PinmemberMember 106138666-Mar-14 21:14 
QuestionNeed DLL PinmemberJasRaj Bishnoi4-Mar-14 22:33 
AnswerRe: Need DLL PinmemberNevs086-Mar-14 20:44 
QuestionRequest Full DLL PinmemberMember 1054130322-Feb-14 22:58 
QuestionHow to get the text box ..text in cs page ex: Textbox1.text Pinmemberrajmohan131112-Feb-14 1:53 
QuestionNeed full dll Pinmemberrajmohan131112-Feb-14 1:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150326.1 | Last Updated 25 Oct 2013
Article Copyright 2013 by Nikhil Awatade
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid