在ASP.NET中调用一个弹出的“确认"消息框 [英] Invoking a pop-up 'confirm' message box in ASP.NET
本文介绍了在ASP.NET中调用一个弹出的“确认"消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
单击按钮后,我知道该怎么做.例如:
I know how to this when a button is clicked. For example:
imgBtnDelete.Attributes.Add("onclick", "return confirm('Please confirm you want to delete the letter')")
我的问题是:
说我有一段与单击无关的代码,计算布尔值,如果布尔值为true,那么我希望显示确定/取消"消息框.
Say I have a piece of code-behind not related to clicking,calculating the value of a boolean, and if the boolean is true then I want the message box with ok/cancel to appear.
f.e.:
bool hasMoney = ...
if (hasMoney)
{
\\message box..
}
我该怎么做?
推荐答案
您可以执行以下操作:
private void OpenConfirmPrompt()
{
string strScript = "<script language=JavaScript>alert('File Uploaded');</script>";
if (!ClientScript.IsStartupScriptRegistered("open"))
{
ClientScript.RegisterStartupScript(typeof(Page), "open", strScript);
}
}
然后更改其中的JS以适合.
And change the JS there to suit.
因此从服务器端事件中调用该函数.
So call that function from a server side event.
编辑,比我更好的解释这里
Edit, much better explanation than me here
这篇关于在ASP.NET中调用一个弹出的“确认"消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文