如何为C#web apllication编写messagebox类 [英] How to write messagebox class for C# web apllication
问题描述
我正在尝试为我的C#web Apllication编写messageBox类。但我得到的错误如下:
找不到类型或命名空间名称'Page'(你是否缺少using指令或汇编引用?)
我尝试过:
public static void显示(字符串消息)
{
if(!handlerPages.Contains(HttpContext.Current.Handler)){
Page currentPage = HttpContext.Current.Handler;
// Page currentPage = HttpContext.Current.Handler;
if((currentPage!= null)){
Queue messageQueue = new Queue ();
messageQueue.Enqueue(Message);
handlerPages.Add(HttpContext.Current.Handler,messageQueue);
currentPage.Unload + = CurrentPageUnload;
}
Im trying to write messageBox Class For my C# web Apllication. But Im getting error as below:
The type or namespace name 'Page' could not be found (are you missing a using directive or an assembly reference?)
What I have tried:
public static void Show(string Message)
{
if (!handlerPages.Contains(HttpContext.Current.Handler)) {
Page currentPage = HttpContext.Current.Handler;
//Page currentPage = HttpContext.Current.Handler;
if ((currentPage != null)) {
Queue messageQueue = new Queue();
messageQueue.Enqueue(Message);
handlerPages.Add(HttpContext.Current.Handler, messageQueue);
currentPage.Unload += CurrentPageUnload;
}
推荐答案
您可以在网页中使用javascript,如下所示:
You can use javascript in the web page, like this:
var r = confirm("Press a button");
if (r == true) {
x = "You pressed OK!";
} else {
x = "You pressed Cancel!";
}
此处有更多信息: JavaScript Popup Boxes [ ^ ]
>
对于简单通知,请使用警报;对于一个可以检测简单按钮单击选择的对话框,使用确认:查找ScriptManager。
对于更高级的东西,你有几种选择;从MS中查看这个:[ ^ ]。
For simple notifications use "Alert;" for a dialog where you can detect simple button-click-choices, use "Confirm:" look up ScriptManager.
For fancier stuff you've got several alternatives; check out this one from MS: [^].
这里有一些参考。
javascript - 警告框
这篇关于如何为C#web apllication编写messagebox类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!