Article: Client side Message Box to ASPX Pages

Article Detail

Posted by:

 

Date:

Tuesday, September 05, 2006 (CST)

 
Screen Shots



Article Brief Description

Client Side Dialog is very common practice in developing an application where we need to ask the user for confirmation or display a message.


Article Detail Description

In this article you will find 2 ways how you can do the client side confirmation dialog.

You can set the Attributes property of a button for onClick. I wrote a generic function that can take control as a paratament and the message as a nother parameter. Below is a sample code

 

public static void CreateConfirmBox(System.Web.UI.WebControls.Button btn, string strMessage)
{
    btn.Attributes.Add("onclick", "return confirm('" + strMessage + "');");
}

 

In ASP.NET 2.0 Button, LinkButton and Imagebutton controls have an OnClientClick property, which makes displaying a confirmation dialog very easy.

 

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" OnClientClick="return confirm('Are you sure you want to delete this item?');" Text="Delete ASP.NET 2.0" Width="191px" />

Average Rating:

Ferotech Solution Services Inc.