C# 检查单击了哪个ASP.NET
我通常隐藏以下divC# 检查单击了哪个ASP.NET,c#,jquery,asp.net,C#,Jquery,Asp.net,我通常隐藏以下div <div id="confirmDialog" class="window" style="background-color:#f2f4f7; border:1px solid #d9a0e2; text-align:center; height:100px; position:fixed; padding:10px; top:50% " runat="server" visible="false"> <br /> You already ha
<div id="confirmDialog" class="window" style="background-color:#f2f4f7; border:1px solid #d9a0e2; text-align:center; height:100px; position:fixed; padding:10px; top:50% " runat="server" visible="false">
<br /> You already have a leave request on the chosen date. Are you sure you want to submit this request?<br /><br />
<asp:Button ID="BtnConfirm" runat="server" Text="Yes" Width="60px" />
<asp:Button ID="BtnNo" runat="server" Text="Cancel" onclick="BtnNo_Click" />
</div>
如何通过asp.net/jQuery实现这一点?可以通过两种方式实现 通过Jquery拦截click事件 在代码中添加其他脚本。
您必须将代码分为两个不同的部分:一个是执行部分,完成后弹出确认对话框,另一个是提交表单以执行其余部分。您不能一次完成这项工作,因为您不能执行服务器端代码,在客户端弹出确认对话框,然后在服务器端继续 你要做的是用伪代码
button1_Click()
{
Execute_logic;
use scriptmanager to trigger a JavaScript function that displays the confirmation dialog;
}
JavaScript函数应该:
function askConfirm()
{
if(confirm('want to continue?'))
submit_the_form to execute second part of the process();
else
return false;
}
服务器端代码:
//This is the method that should execute after the JavaScript function submits the form
Handler_ForSecondPartOfTheRequest()
{
execute second part of the logic;
}
检查发送方对象,它将返回控制信息。
function askConfirm()
{
if(confirm('want to continue?'))
submit_the_form to execute second part of the process();
else
return false;
}
//This is the method that should execute after the JavaScript function submits the form
Handler_ForSecondPartOfTheRequest()
{
execute second part of the logic;
}