Click here to Skip to main content
15,891,033 members
Articles / Web Development / ASP.NET

ASP.NET Popup Control

Rate me:
Please Sign up or sign in to vote.
4.87/5 (617 votes)
21 Apr 2004Ms-PL5 min read 3.3M   98.5K   1.2K  
Highly customizable JavaScript popup control for web page wrapped in ASP.NET custom control.
Public Class WebForm1
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

  End Sub
  Protected WithEvents dropDrag As System.Web.UI.WebControls.DropDownList
  Protected WithEvents Label6 As System.Web.UI.WebControls.Label
  Protected WithEvents btnBob As System.Web.UI.WebControls.Button
  Protected WithEvents btnTwo As System.Web.UI.WebControls.Button
  Protected WithEvents Label5 As System.Web.UI.WebControls.Label
  Protected WithEvents popDocking As System.Web.UI.WebControls.DropDownList
  Protected WithEvents btn4Ever As System.Web.UI.WebControls.Button
  Protected WithEvents Label4 As System.Web.UI.WebControls.Label
  Protected WithEvents clrStyle As System.Web.UI.WebControls.DropDownList
  Protected WithEvents Label3 As System.Web.UI.WebControls.Label
  Protected WithEvents textTitle As System.Web.UI.WebControls.TextBox
  Protected WithEvents textFull As System.Web.UI.WebControls.TextBox
  Protected WithEvents Label2 As System.Web.UI.WebControls.Label
  Protected WithEvents textMsg As System.Web.UI.WebControls.TextBox
  Protected WithEvents Label1 As System.Web.UI.WebControls.Label
  Protected WithEvents btnPopup As System.Web.UI.WebControls.Button
  Protected WithEvents popupBob As EeekSoft.Web.PopupWin
  Protected WithEvents popupWin2 As EeekSoft.Web.PopupWin
  Protected WithEvents popupWin As EeekSoft.Web.PopupWin

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    popupBob.Visible = False
    popupWin.Visible = False
    popupWin2.Visible = False
  End Sub

  Private Sub btnPopup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPopup.Click
    popupWin.HideAfter = 5000
    popupWin.Visible = True
    popupWin.Title = textTitle.Text
    popupWin.Message = textMsg.Text
    popupWin.Text = textFull.Text
    popupWin.DragDrop = (dropDrag.SelectedIndex = 0)
    If popDocking.SelectedIndex = 0 Then popupWin.DockMode = EeekSoft.Web.PopupDocking.BottomLeft
    If popDocking.SelectedIndex = 1 Then popupWin.DockMode = EeekSoft.Web.PopupDocking.BottomRight
    popupWin.ColorStyle = Switch(clrStyle.SelectedIndex = 0, EeekSoft.Web.PopupColorStyle.Red, clrStyle.SelectedIndex = 1, EeekSoft.Web.PopupColorStyle.Green, clrStyle.SelectedIndex = 2, EeekSoft.Web.PopupColorStyle.Blue, clrStyle.SelectedIndex = 3, EeekSoft.Web.PopupColorStyle.Violet)
    popupWin2.Visible = False
  End Sub

  Private Sub btn4Ever_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4Ever.Click
    popupWin.HideAfter = -1
    popupWin.Visible = True
    popupWin.Title = textTitle.Text
    popupWin.Message = textMsg.Text
    popupWin.Text = textFull.Text
    popupWin.DragDrop = (dropDrag.SelectedIndex = 0)
    popupWin.DockMode = Switch(popDocking.SelectedIndex = 0, EeekSoft.Web.PopupDocking.BottomLeft, popDocking.SelectedIndex = 0, EeekSoft.Web.PopupDocking.BottomRight)
    popupWin.ColorStyle = Switch(clrStyle.SelectedIndex = 0, EeekSoft.Web.PopupColorStyle.Red, clrStyle.SelectedIndex = 1, EeekSoft.Web.PopupColorStyle.Green, clrStyle.SelectedIndex = 2, EeekSoft.Web.PopupColorStyle.Blue, clrStyle.SelectedIndex = 3, EeekSoft.Web.PopupColorStyle.Violet)
    popupWin2.Visible = False
  End Sub

  Private Sub btnBob_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBob.Click
    popupBob.Visible = True
  End Sub

  Private Sub btnTwo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTwo.Click
    btnPopup_Click(sender, e)
    popupWin2.DockMode = popupWin.DockMode
    popupWin2.DragDrop = (dropDrag.SelectedIndex = 0)
    popupWin2.Visible = True
  End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Czech Republic Czech Republic
I live in Prague, the capital city of Czech republic (most of the time Smile | :) ). I've been very interested in functional programming recently and I have a passion for the new Microsoft F# language. I'm writing a book about Functional Programming in the Real World that shows the ideas using examples in C# 3.0 and F#.

I've been Microsoft MVP (for C#) since 2004 and I'm one of the most active members of the F# community. I'm a computer science student at Charles University of Prague. My hobbies include photography, fractals and of course many things related to computers (except fixing them). My favorite book writers are Terry Pratchett and Philip K Dick and I like paintings by M. C. Escher.

PS: My favorite codeproject icon is Sheep | [baah] .

Comments and Discussions