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

Popup Control for ASP.NET

By , 25 Oct 2013
Rate this:
Please Sign up or sign in to vote.

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)

About the Author

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

Comments and Discussions

 
Questiondll needed urgently Pinmemberdeepak23089015-Apr-14 18:03 
QuestionNeed dll Pinmembersree_jisha9-Apr-14 17:15 
QuestionExpired Pinmemberkreattor20-Mar-14 8:14 
Questionresolved :) PinmemberJasRaj Bishnoi10-Mar-14 20:44 
QuestionExpired PinmemberMember 106574149-Mar-14 23:51 
QuestionNeed DLL PinmemberMember 106138666-Mar-14 20:14 
QuestionNeed DLL PinmemberJasRaj Bishnoi4-Mar-14 21:33 
AnswerRe: Need DLL PinmemberNevs086-Mar-14 19:44 
QuestionRequest Full DLL PinmemberMember 1054130322-Feb-14 21:58 
QuestionHow to get the text box ..text in cs page ex: Textbox1.text Pinmemberrajmohan131112-Feb-14 0:53 
QuestionNeed full dll Pinmemberrajmohan131112-Feb-14 0:02 
Question't Pinmembermano444-Feb-14 6:58 
QuestionNeed complete DLL Pinmembernijakanthan30-Jan-14 8:35 
QuestionDLL without the 100 clicks restriction PinmemberMember 1001269030-Jan-14 4:06 
Questioncomplete dll Pinmemberthabang0224-Jan-14 3:14 
QuestionHow to style the generated popup ? PinmemberRilcy7523-Jan-14 1:09 
Questioncan i change c the color of the header text or change the close icon? Pinmemberhoggydos21-Jan-14 20:56 
QuestionI need your dll Pinmembertannguyen0321-Jan-14 20:20 
QuestionWhere from i will find ASP.Web.UI.PopupControl PinmemberMERAZ_UDDIN7-Jan-14 23:53 
Questioncomplete dll for popup PinmemberMember 1043021327-Nov-13 7:36 
GeneralMy vote of 5 PinmemberMember 103518147-Nov-13 0:58 
QuestionThank you for this it saves a lot of work. PinmemberMember 103518147-Nov-13 0:54 
QuestionWhy does the control expire after 100 clicks? PinmemberMember 790852930-Oct-13 9:45 
AnswerRe: Why does the control expire after 100 clicks? PinmemberNikhil Awatade5-Nov-13 3:58 
GeneralRe: Why does the control expire after 100 clicks? PinmemberMember 79085295-Nov-13 4:03 

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 | Mobile
Web04 | 2.8.140415.2 | Last Updated 25 Oct 2013
Article Copyright 2013 by Nikhil Awatade
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid