5

I want to add/show some message with a OK button in c# asp.net without using the windows.forms name space.

2
  • 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. Commented Feb 9, 2014 at 4:25
  • @SimonWhitehead not alert() Commented Feb 9, 2014 at 12:04

3 Answers 3

12

Use:

string display = "Pop-up!";
            ClientScript.RegisterStartupScript(this.GetType(), "yourMessage", "alert('" + display + "');", true);

how to show alert box after successful insert using C#

YES OR NO MessageBox

Buttons, Message Box, and Confirm Box in ASP.NET 3.5

Easiest way to do a message box with an ok button??

How to show MessageBox in ASP.NET (CSASPNETMessageBox)

Sign up to request clarification or add additional context in comments.

2 Comments

Jefri thanks for the links! They helped a lot
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
0

Ext JS got some good message box scripts, check this out, it will help you Ext JS MessageBox Dialogs

Comments

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);
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.