处理Web应用程序中确认框的“确定”按钮事件。 [英] Handle the Ok button event of confirmation box in web application.
问题描述
我在modalpopupextender上有一个提交按钮。
我必须在提交按钮内的特定条件下打开一个确认框。
我可以打开确认但是,当用户点击确定按钮确认框时,我想要执行一些代码。
如何处理确认框的确定按钮事件?
这是我的代码:
I have a submit button on modalpopupextender.
I have to open a confirmation box on a specific condition inside the submit button.
I am able to open the confirmation box.But when user clicks on the ok button
of the confirmation box i want to execute some code.
How can i handlethe event of Ok button of the confirmation box?
Here is my code:
protected void BtnSubmitSurveyInfo_Click(object sender, EventArgs e)
{
if()
{
//some code.
}
else
{
BtnSubmitSurveyInfo.Attributes.Add("onclick", "if(confirm('Confirm - Are you sure you want to go ahead.')) onConfirm(); else return false;");
}
}
推荐答案
你想要的代码执行,你的语法错了
which code you want to execute and your syntax is wrong
BtnSubmitSurveyInfo.Attributes.Add("onclick", " var aa=confirm('Confirm - Are you sure you want to go ahead.')if (aa==true){your code}else {your code}");
这个我们也很方便
[更新]
this would we also handy
[update]
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "script", "<script type='text/javascript'>var x = window.confirm('Do you want to assign pages to this advertise?');if(x){code}</script>", false);
问候....:)
regards....:)
试试这样:
Hi,
Try like this:
<html>
<head>
<pre lang="Javascript"><script>
function myFunction()
{
if(confirm("Do You want to Execurte Below Code?")){
//code to execute when click on Yes
}else{
//else
}
}
</script>
< / head>
< body>
< asp:Button ID =btnTestOnClientClick =return myFunction();Text =Show Confirmrunat =server/> < br $> b $ b
< / body>
< / html>
</head>
<body>
<asp: Button ID="btnTest" OnClientClick="return myFunction();" Text="Show Confirm" runat="server" />
</body>
</html>
这篇关于处理Web应用程序中确认框的“确定”按钮事件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!