Forum guidelines
AuthorQuestion
Message Box in asp.net/ c#
Posted By Imran Pervez on 11 Oct 2010


i want to show message in messagebox "Data Saved successfully" when click submit botton
i use below code but message box not show plz send me solution for this
protected void btnSaveUpdate_Click(object sender, EventArgs e)
{

objclscp_BlockFngoTargets.Insert(
);
MessageBox(
"Data Saved Successfully !");

}
private void MessageBox(string msg)
{
Label lbl = new Label();
lbl.Text =
"<script language='javascript'>" + Environment.NewLine + "window.alert('" + msg + "')</script>";
Page.Controls.Add(lbl);
}

 
but above code not give any responce
i also use one more code but same problem
private void MessageBox(string message)
{
if (!string.IsNullOrEmpty(message))
{
Response.Write("<script type=\"text/javascript\" language=\"javascript\">");
Response.Write("alert('" + message + "');");
Response.Write("</script>");
}
}


  
  
 

AuthorReply
Re: Message Box in asp.net/ c#
Posted By Gomathi Palaniswamy on 11 Oct 2010  
Hi friend,

use below namespace
using System.Windows.Forms;

With Regards,
Gomathi.P
Re: Message Box in asp.net/ c#
Posted By Imran Pervez on 11 Oct 2010  
this assembly not show

Re: Message Box in asp.net/ c#
Posted By Aaron Colen on 11 Oct 2010  
The default message box for C#/.net is System.Windows.Forms.MessageBox.

To use it you will need the using statement that Gomathi posted.

Then you call it with MessageBox.Show("Your text here");


Re: Message Box in asp.net/ c#
Posted By theLizard on 11 Oct 2010  
Try this
if (!string.IsNullOrEmpty(message))
{

      Response.Write("<script>alert('saved...')</script>");
}

theLizard

Re: Message Box in asp.net/ c#
Posted By theLizard on 11 Oct 2010  
Try this
if (!string.IsNullOrEmpty(message))
{

      Response.Write("<script>alert(message)</script>");
}

theLizard

Re: Message Box in asp.net/ c#
Posted By Imran Pervez on 12 Oct 2010  
i add reference
System.Windows.Forms
and use messagebox.show("my text");
my issue is : messagebox show but not show as a dialogbox (user can work with form whitout closing this message box)

Re: Message Box in asp.net/ c#
Posted By Imran Pervez on 12 Oct 2010  
thanks this is right for me
Re: Message Box in asp.net/ c#
Posted By Raj Kumar Beniwal on 12 Oct 2010  


You can use like this.

Private Sub DisplayClientError(ByVal errorDesc As String)
   Dim script As String = "alert('" + errorDesc + "');"
   ScriptManager.RegisterStartupScript(Me, GetType(Page), "UserSecurity", script, True)
End Sub

Protected Sub ClickButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ClickButton.Click
   If TextBox1.Text = "" Then
   DisplayClientError("Enter some text in text box")
End If
 
http://www.c-sharpcorner.com/UploadFile/raj1979/MessageBox12022007154420PM/MessageBox.aspx

Developer | Consultant | Project Manager | Microsoft MVP | C# MVP
Re: Message Box in asp.net/ c#
Posted By Imran Pervez on 12 Oct 2010  

i want to use this alert box on button click when use save data and show message "data saved successfully"
as your's responce artical i able to show message box(alert) but
my issue is : alert message box icon is show(error icon) i want remove this icon if this not possible what is anothe way for this
 

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.