people face lot of problems in creating message boxes like in desktop applications in asp.net, there are lot of ways of calling javascript alerts, but here i would explain how to generate a message box in asp.net..
for that , create a class and name it Messages.cs in App_Code. the class will have a single method to generate the message box like as follows
-
-
using System;
-
using System.Collections.Generic;
-
using System.Linq;
-
using System.Web;
-
using System.Web.UI;
-
-
/// <summary>
-
/// Summary description for Messages
-
/// </summary>
-
public class Messages
-
{
-
public Messages()
-
{
-
//
-
// TODO: Add constructor logic here
-
//
-
}
-
-
-
public void CreateMessageAlert(string strMessage)
-
{
-
Guid guidKey = Guid.NewGuid();
-
Page pg = (Page)HttpContext.Current.Handler;
-
string strScript = "alert('" + strMessage + "');";
-
pg.ClientScript.RegisterStartupScript(pg.GetType(), guidKey.ToString(), strScript, true);
-
}
-
}
-
-
now in your page where ever you want to display an OK message box , you can call like this
-
Messages myMsg=new Messages(); // create the object
-
myMsg.CreateMessageAlert("Your Message Here");
-
-
...
Addan