Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Show Dialog Box Without Use of ModalPopupExtender

27 Nov 2014 1  
Show dialog box with very few lines of code

Introduction

If you want to show Dialog box over your page, on click event of control, then you will use ModalPopExtender, which is Ajax Control, so instead of using this, I am giving one solution how to show Dialog box over Page which will be block Background, show title of Dialog Box, show message in Dialog Box.

Using the Code

    <style type="text/css">           
 
        .ui-dialog {            
            width: 400px !important;
            position: fixed;            
            height: 100%;
            display:block;
            z-index: 10;
            outline: 9999px solid rgba(0,0,0,0.5);
        }
       
    </style>
<asp:Panel ID="dialogPanel" 
runat="server" Visible="false" EnableViewState="false">

        <div id="dialogBox" title="VENTAS COSTES TOTAL INFORMACION"> 
        <%--informaciĆ³n total de los costos de ventas--%>
            <p>
                <% =ViewState["dialogMessage"].ToString() %>
            </p>
        </div>
    </asp:Panel>

In .cs file , you need to enter these lines only on control click event:

///<summary>
/// Shows the Dialog Box with message
///
private void ShowDialogBox()
{
string message= string.Empty();
message= "Here you can write what you want to display in Dialog Box";
ViewState["dialogMessage"] = message;
dialogPanel.Visible = true;
}

Points of Interest

Here, you do not need to worry about Close button click event , when you click on Close Image, Dialog Box disappears from the screen.

History

  • 27th November 2014: Initial version

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here