如何使用C#(请帮助)在ASP.NET中显示消息框但是messagebox.show会导致错误原因? [英] HOW TO DISPLAY MESSAGEBOX IN ASP.NET USING C# (PLEASE HELP) but messagebox.show conduct the error why?

查看:76
本文介绍了如何使用C#(请帮助)在ASP.NET中显示消息框但是messagebox.show会导致错误原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有messagebox.show

in the namespace not have messagebox.show

推荐答案

Nup,在Asp.net中使用messagebox.show是一个坏主意。你可以使用javascript来做同样的事情。

http://www.w3schools.com/js /js_popup.asp [ ^ ]

http://dhtmlx.com/docs/products/dhtmlxMessage/index.shtml [ ^ ]



如果你想从后面的代码中显示消息框,那么你可以使用 ScriptManager类 [ ^ ]向页面注册javascript。试试这个

Nup, using messagebox.show in Asp.net is a bad idea. you can use javascript to do the same.
http://www.w3schools.com/js/js_popup.asp[^]
http://dhtmlx.com/docs/products/dhtmlxMessage/index.shtml[^]

If you want to show messagebox from code behind then you can use ScriptManager Class[^] to register javascript with page. Try this
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "Myscript1", @"alert('Hi am a alert box');", true);







- Amit

问题



消息框用于Windows窗体。您仍然可以使用它,但这不会反映在客户端。



解决方案



因此,您需要使用 javaScript alert 确认框。

Problem

Message Box is for Windows Forms. You can still use it, but that will not reflect at client side.

Solution

So, you need to use javaScript alert or confirm box.
  • Alert Box from Code Behind
    Re: MessageBox.Show in ASP.Net[^]
  • Confirm Box from Code Behind
    Confirmation box from server side in asp.net[^]


最简单方式:



Simplest way:

Response.Write("<script type='text/javascript'>");
Response.Write("alert('There does not exist any simpler alert then this.');");
Response.Write("</script>");





问候......:笑:



Regards.. :laugh:


这篇关于如何使用C#(请帮助)在ASP.NET中显示消息框但是messagebox.show会导致错误原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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