Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Web Application Message Box

In an asp.net windows forms application, in the C# code behind you can use:

MessageBox.Show("Here is my message"); 

Is there any equivalent in a asp.net web application? Can I call something from the C# code behind that will display a message box to the user?

Example usage of this: I have a button that loads a file in the code behind. When the file is loaded or if there is an error I would like to popup a message to the user stating the result.

Any ideas on this?

like image 781
Baxter Avatar asked Mar 15 '12 12:03

Baxter


People also ask

What is MessageBox in asp net?

Show function in ASP.Net using C# and VB.Net. Since ASP.Net is a Web technology i.e. Client Server technology, the messages needs to be displayed with the help of JavaScript Alert Message Box where JavaScript is a Client Side script which runs within Browser. Display Message when user visits the page.


1 Answers

You want to use an Alert. Unfortunately it's not as nice as with windows forms.

ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true); 

Similar to this question here: http://forums.asp.net/t/1461308.aspx/1

like image 200
Gage Avatar answered Oct 12 '22 06:10

Gage