Alert Message using C#

Usually we generate Alert Message using Java Script in our .aspx page. But we can also generate an Alert Message from out Code behind page using C# and JavaScript. Below is the code which will display the Alert Message up on Button Click.

1
2
3
4
5
6
7
8
9
10
     private void MessaegBox(String msg)
        {
   Page.Controls.Add(new LiteralControl("window.alert('" + msg + "')"));
        }
 
        protected void btnAlertMsg_Click(object sender, EventArgs e)
        {
            String msg1 = "Are You sure..........";
            MessaegBox(msg1);
        }

Share Article/Example:
  • DotNetKicks
  • DZone
  • StumbleUpon
  • Print
  • Add to favorites
  • Digg
  • del.icio.us
  • Twitter
  • Facebook
  • LinkedIn
  • Posterous
  • Slashdot

Filed Under: Language Basics

Tags:

RSSComments (0)

Trackback URL

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.