I want to add/show some message with a OK button in c# asp.net without using the windows.forms name space.
Asked
Active
Viewed 6.7k times
5
-
Oh my, this is a big question. I think you need to read about how the web works. You cannot use c# to show a messagebox because the c# is running on the server and you want the messagebox to appear in the browser. There is no guarantee the users computer even has .Net installed. Instead you will likely use some form of javascript to show it. – George Mauer Feb 09 '14 at 04:25
-
@SimonWhitehead not alert() – Shaivya Sharma Feb 09 '14 at 12:04
3 Answers
12
Use:
string display = "Pop-up!";
ClientScript.RegisterStartupScript(this.GetType(), "yourMessage", "alert('" + display + "');", true);
how to show alert box after successful insert using C#
Buttons, Message Box, and Confirm Box in ASP.NET 3.5

Community
- 1
- 1
-
-
Jefri I have tried the code form the link for Yes or No message box and it works. It shows the message with two buttons, Ok and Cancel. But I do not know how to capture OK or Cancel response in my c# code. Can you please help? Because I need to write c# code based on the response – Shaivya Sharma Feb 10 '14 at 06:34
0
Ext JS got some good message box scripts, check this out, it will help you Ext JS MessageBox Dialogs

Raju Melveetilpurayil
- 472
- 3
- 10
0
public void Message(String msg)
{
string script = "window.onload = function(){ alert('";
script += msg;
script += "');";
script += "window.location = '";
script += "'; }";
ClientScript.RegisterStartupScript(this.GetType(), "Redirect", script, true);
}

Pawan
- 1