I was attempting to add MessageBox.Show(Message);
and it was not found in my C# .net web application (button click method and also in Page_Load
).An error showing like
'The name 'MessageBox' does not exist in the current context'
Do I need to add any assembly reference for this? (I am using .net framework 4). Is there any alternative method for this?
A message box is a special dialog box used to display a piece of information to the user. As opposed to a regular form, the user cannot type anything in the dialog box. To support message boxes, the Visual Basic language provides a function named MsgBox.
To display a message box, call the static method MessageBox. Show. The title, message, buttons, and icons displayed in the message box are determined by parameters that you pass to this method.
The second button on the message box is the default button.
A message box is a prefabricated modal dialog box that displays a text message to a user. You show a message box by calling the static Show method of the MessageBox class. The text message that is displayed is the string argument that you pass to Show.
The key words in your description are
web application
This functionality is only available in client (WinForms, WPF) based applications, not ASP.NET. To do this in a web app you will need to use Javascript, as illustrated in this previous Stack Overflow question.
Use This:
System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('" + Message + "')", true);
Hope This help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With