如何在java脚本中单击弹出我的字符串 [英] How do I popup my string in java script onclick

查看:59
本文介绍了如何在java脚本中单击弹出我的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "clientscript", "alert('" + mystring+ "')", true);







我需要弹出一个警告框



我的尝试:






I need to pop up not an alert box

What I have tried:

ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "clientscript", "alert('" + mystring+ "')", true);

推荐答案

RegisterClientScriptBlock只是将代码放入页面,但您需要调用它。或者,您可以使用 ClientScriptManager.RegisterStartupScript方法(类型,字符串,字符串,布尔值) )(System.Web.UI) [ ^ ]会为你调用它。



然而,从C#调用弹出窗口可以很好地表明你可以设计很差,所以我首先要重新考虑你要做的事情。
RegisterClientScriptBlock just puts the code into the page but you then need to call it. Or, you can use ClientScriptManager.RegisterStartupScript Method (Type, String, String, Boolean) (System.Web.UI)[^] which will call it for you.

However, calling a popup from C# is a good indication that you may have a poor design so I would first have you reconsider what you are trying to do.


之前添加这个作为评论,以便立即帮助OP,并在的反馈之后Karthik Bangalore 将其作为解决方案发布。



给定链接为所述问题提供了一个很好的详细解决方案。



显示来自Asp.Net Webforms的Bootstrap模式





希望有所帮助秒。 :)
Added this before as a comment to help immediately to the OP and after the feedback from "Karthik Bangalore" posting it as a solution.

The given link provides a good detailed solution for the described problem.

Display Bootstrap Modal from Asp.Net Webforms


Hope it helps. :)


使用以下行:

写入代码隐藏中按钮的单击事件

ScriptManager.RegisterClientScriptBlock(Me.Page ,GetType(页面),消息,< script type =text / javascriptlanguage =javascript> alert(+ mystring +);< / script> ,False)
Use following line:
Write in on click event of the button in codebehind
ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(Page), "message", "<script type=""text/javascript"" language=""javascript"">alert("" " + mystring + " "");</script>", False)


这篇关于如何在java脚本中单击弹出我的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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