简体   繁体   中英

How to show popup message box in ASP.NET?

Work on C# VS 2005 AJAX enabled web. I want to show a pop up message on my web page. In my desktop application I write the following code to show a message:

MessageBox.Show("Data Saved Successfully.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);

I want this kind of message. Where i can set message icon, Message Header, Message text....I write a code for web :

s = "<script type=\"text/javascript\">alert('InCorrect DateFormat. Check Required.');</script>";
ClientScript.RegisterStartupScript(GetType(), "Alert", s);

Why it's not work ....And how to get message like desktop application.

my button under the ajax update panel.After click data save but message is not show....if i put button out the update panel it's work show pop up message ....but i want button must stay on update panel

Your second code-snippet works for me, it shows the message box when the page is loaded in the browser.

Do you get any error message? Can you show some more code?

Regarding your second question: I don't think you can get the same message box as in the windows forms application (at least not with the standard javascript alert method). If you really want to have an equal looking dialog (with icons), then you might have to search for some 3rd-party library (like jQuery (-UI), ExtJS , etc.).

Update (regarding UpdatePanel):

According to this forum post , you should use ScriptManager.RegisterClientScriptBlock() instead of Page.ClientScript.RegisterClientScriptBlock(), but I think this is only available since .NET 3.5. For your case, you might want to try a workaround such as shown in this question .

Have you tried different browsers such as IE, FireFox, or Chrome. Make sure that you don't have pop-up blocker?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM