I tried to add MessageBox.Show(Message); and was not found in my C # .net web application (button click method, as well as in Page_Load ). Error showing how
MessageBox.Show(Message);
Page_Load
'The name MessageBox does not exist in the current context
Do I need to add assembly links? (I am using .net framework 4). Is there an alternative method for this?
Use this:
System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('" + Message + "')", true);
Hope this help.
The keywords in your description are
web application
This function is available only in client (WinForms, WPF) applications, and not in ASP.NET. For this, in a web application you will need to use Javascript, as shown in the previous stack overflow question .
The MessageBox class in the System.Windows.Forms can be used from Windows Forms and not from ASP.NET Web Forms.
MessageBox
System.Windows.Forms
Windows Forms
System.Windows.MessageBox used in WPF applications and System.Windows.Forms.MessageBox used in Windows Form applications , but your project is WebApplication , so you donโt have access to any of them.
System.Windows.MessageBox
System.Windows.Forms.MessageBox