我有一个LinkButton
在视图上称为“退出聊天”。我嵌入javascript
编码成OnClientClink=javascript:confirm('Are you sure you want to end the session?')
.但是,我无法管理对话框
当用户单击“确定”按钮时,视图应终止。我该如何执行此操作?
<asp:LinkButton ID="LinkButton2" runat="server" Font-
Bold="False" Font-Underline="False"
OnClientClick="javascript:confirm('Are you sure you want to end the session?')"
ViewStateMode="Enabled" OnClick="LinkButton2_Click1" Text="Exit Chat">
</asp:LinkButton>
我写了这个代码部分但没有工作:(
if (LinkButton2.CommandName=="OK")
{
MultiView1.ActiveViewIndex = -1;
}
else if(LinkButton2.CommandName=="Cancel")
{
MultiView1.ActiveViewIndex = 1;
}
您可以检查确认结果,如果正确则关闭窗口。
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete"
OnClientClick="return showConfirm();">
</asp:LinkButton>
<script>
function showConfirm()
{
var ok = confirm('Are you certain you want to delete this product?');
if (ok)
{
window.close();
}
}
<script>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)