Monday, May 20, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
107
rated 0 times [  108] [ 1]  / answers: 1 / hits: 30204  / 13 Years ago, mon, february 20, 2012, 12:00:00

I have a page that contains a textbox and button, when the user clicks the submit button I want to display a message based on a bool value.



I have researched on stackoverflow and tried the code in this questions: Asp.net Webform Display Alert and redirect



But it didn't work. I have the following code:



ClientScript.RegisterStartupScript(this.GetType(),, alert('message'), true);


What code do I need to display the alert message?


More From » c#

 Answers
27

you can use this simple method:



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

[#87329] Sunday, February 19, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
quinn

Total Points: 160
Total Questions: 86
Total Answers: 101

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
;