Home > error message > error message box in c# asp.net

Error Message Box In C# Asp.net

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ASP.NET Web Application Message Box up vote 18 down vote favorite 4 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? c# asp.net web-applications code-behind messagebox share|improve this question asked Mar 15 '12 at 12:55 Baxter 1,676114482 add a comment| 12 Answers 12 active oldest votes up vote 49 down vote accepted 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 share|improve this answer answered Mar 15 '12 at 12:59 Gage 4,94452965 1 What is myStringVariable?? –stylojack_10 Mar 23 '13 at 5:11 3 myStringVariable is just a string. It would be set to the message you wish to display. –Gage Mar 25 '13 at 20:02 @Gage When the message box opens following the event being triggered, the user is presented with an 'OK' button. Is there anyway to wire up a Response.Redirect("desired/path.aspx"); to this? –JsonStatham Jul 25 '14 at 14:30 When I try this I just get No overload for method 'RegisterStartupScript' takes 4 arguments –Bassie Jul 7 at 10:34 add a comment| up vote 12 down vote Or create a method like this in your solution: public static class MessageBox { public static void Show(this Page Page, String Message) { Page.ClientScript.RegisterStartupScript( Page.GetType(), "MessageBox", "

 

© Copyright 2019|winbytes.org.