Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
4.00/5 (3 votes)
See more:
I want to create a message box in asp.net web application any help..
Posted
Comments
rockpune 9-Feb-12 5:45am    
u can take lable in asp.net there is no any options to get the messagebox

To make your web application efficient you can add one class named MessageBox in your AppCode folder.
please cheak this link
www.codeproject.com/KB/webforms/AspNetMsgBox.aspx[^]
 
Share this answer
 
Try this,

public void MsgBox1(string msg, Page refP)
   {
       Label lbl = new Label();
       string lb = "window.alert('" + msg + "')";
       ScriptManager.RegisterClientScriptBlock(refP, this.GetType(), "UniqueKey", lb, true);
       refP.Controls.Add(lbl);
   }


Put your function in cs file(i.e. yourclass.cs file)And call the function like:
MsgBox1("Your Message",this);
 
Share this answer
 
I would suggest that you use Label control and use color red or green.

Another option is to use Javascript alert.
 
Share this answer
 
 
Share this answer
 
you Can try below code.

C#
Page.ClientScript.RegisterStartupScript(this.GetType(),"Hello","javascript:alert("Give Message Here");",true);


try Below link

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ModalPopup/ModalPopup.aspx[^]
 
Share this answer
 
C#
  public void fnAlert(string str)
  {
    string alertScript = "<script language="JavaScript">";
    alertScript += "alert('" + str + "');";
    alertScript += ";        
    if (!ClientScript.IsClientScriptBlockRegistered("alert"))
         ClientScript.RegisterStartupScript(typeof(string),"alert", alertScript);
  }

</script>
 
Share this answer
 
try this

C#
try
{
throw new Exception("<script language="javascript">\n" + "alert('abc');" + "</script>");
}

catch(Exception ex)
{
   label1.text = ex.message.text;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900