如何使用C#在asp.net中显示msgbox [英] how to display msgbox in asp.net using C#

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

问题描述

如何使用javascript

how to display msgbox in asp.net(C#) using javascript

推荐答案



为此,您可以使用当前页面的ClientScriptManager.

这是一个示例:

Hi,

For this, you can use the ClientScriptManager of the current page.

Here is an example:

ClientScript.RegisterStartupScript(typeof(_Default), "Message", "alert(''Hello World'');", true);



说明:



Explanation:

ClientScript.RegisterStartupScript(
   <<a type to identify the script source>>,
   <<a unique script identifier, used for not rendering the same script twice>>,
   <<the js code to be pasted in the output rendering>>,
   <<defines if a script tag should be written around your script>>);



这里是MSDN的解释: http://msdn.microsoft.com /en-us/library/system.web.ui.clientscriptmanager.registerstartupscript.aspx [



Here the explanation from the MSDN: http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerstartupscript.aspx[^]


Hope this helps.

Best regards and happy coding :)
Stops


您得到的答案是正确的,但只需要警报部分即可显示消息.您还可以根据需要使用按钮的ClientClick事件,或直接在ASPX中放置的任何其他JavaScript来显示消息框.
The answer you got is right, but only the alert part, is needed to show a message. You could also use the ClientClick event of a button, or any other javascript you may put direct in your ASPX to show a message box, depending on your needs.


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

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