如何显示ASP.NET弹出消息框? [英] How to show popup message box in ASP.NET?

查看:688
本文介绍了如何显示ASP.NET弹出消息框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#的VS 2005支持AJAX的Web工作。我想告诉我的网页上弹出消息。在我的桌面应用程序,我写了下面的code显示一个消息:

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

我想这样的消息。我在哪里可以设置邮件图标,消息头,消息文本....我写了一个code为网络:

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.

我的阿贾克斯更新panel.After点击保存数据,但消息没有显示....如果我把按钮进行更新面板下按钮,它的工作显示弹出消息....但我想按钮必须留在更新面板

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

推荐答案

你的第二个code-片段工作对我来说,它表明,当页面在浏览器中加载消息框。

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

你得到任何错误讯息?你能告诉更多code?

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

关于你提到的第二个问题:我不认为你可以得到相同的消息框作为Windows窗体应用程序(至少不符合标准的JavaScript警告方法)。如果你真的希望有一个平等对话看(带图标),那么你可能需要寻找一些第三方库(如 jQuery的( - UI), ExtJS的等)

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.).

更新(有关的UpdatePanel):

Update (regarding UpdatePanel):

根据这个论坛帖子,你应该使用ScriptManager.RegisterClientScriptBlock(),而不是Page.ClientScript.RegisterClientScriptBlock(),但我认为这仅仅是因为.NET 3.5可用。对于你的情况,你可能想尝试一种变通方法,如所示<一个href=\"http://stackoverflow.com/questions/1190549/how-can-i-run-some-javascript-after-an-update-panel-refreshes\">in这个问题。

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.

这篇关于如何显示ASP.NET弹出消息框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆