如何显示在asp.net的MessageBox? [英] How to show MessageBox on asp.net?

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

问题描述

如果我需要显示在我的ASP.NET的WebForm一个MessageBox,该怎么办呢?

if I need to show a MessageBox on my ASP.NET WebForm, how to do it?

我尝试: Messagebox.show(DD);

但它不工作。

推荐答案

的MessageBox在ASP.NET中并不存在。如果您在浏览器中需要的功能,如显示一个消息框,那么你需要选择的的JavaScript 。 ASP.NET提供了手段注入其中被渲染和执行时的HTML发送到浏览器的加载和显示的JavaScript。您可以使用下面的code在Page_Load例如:

MessageBox doesn't exist in ASP.NET. If you need functionality in the browser, like showing a message box, then you need to opt for javascript. ASP.NET provides you with means to inject javascript which gets rendered and executed when the html sent to the browser's loaded and displayed. You can use the following code in the Page_Load for example:

Type cstype = this.GetType();

// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;

// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, "PopupScript"))
{
    String cstext = "alert('Hello World');";
    cs.RegisterStartupScript(cstype, "PopupScript", cstext, true);
}

这样的采取从MSDN

这篇关于如何显示在asp.net的MessageBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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