管理LinkBut​​ton的使用Javascript? [英] Managing LinkButton with Javascript?

查看:85
本文介绍了管理LinkBut​​ton的使用Javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的LinkBut​​ton 所谓退出聊天关于view.I嵌入的JavaScript code成 OnClientClink = JavaScript的:确认('?您确定要结束会话')。但是,我不能管理对话框

当用户点击OK按钮,查看应该是我terminated.How可以做到这一点?

 < ASP:LinkBut​​ton的ID =LinkBut​​ton2=服务器字体 - 
    粗体=FALSE字体下划线=FALSE
    的OnClientClick =JavaScript的:确认('?您确定要结束会话')
    ViewStateMode =启用的OnClick =LinkBut​​ton2_Click1文本=退出聊天>
< / ASP:LinkBut​​ton的>

我写这篇code部分,但没有工作:(

 如果(LinkBut​​ton2.CommandName ==OK)
{
    MultiView1.ActiveViewIndex = -1;
}
否则,如果(LinkBut​​ton2.CommandName ==取消)
{
    MultiView1.ActiveViewIndex = 1;
}


解决方案

您可以检查确认的结果,如果真然后关闭窗口。

 < ASP:LinkBut​​ton的ID =DeleteButton=服务器的CausesValidation =FALSE
        的CommandName =删除文本=删除
        的OnClientClick =返回showConfirm();>
< / ASP:LinkBut​​ton的><脚本>
功能showConfirm()
{
   VAR OK =确认(你确定要删除这个产品吗?');   如果(OK)
   {
      window.close()的;
   }
}
<脚本>

I have a LinkButton called "Exit Chat" on the view.I embed javascript code into OnClientClink=javascript:confirm('Are you sure you want to end the session?').However,I can't manage dialog box

When user click the OK button,view should be terminated.How can I do this?

<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>

I wrote this code part but didnt work :(

if (LinkButton2.CommandName=="OK")
{
    MultiView1.ActiveViewIndex = -1;
}
else if(LinkButton2.CommandName=="Cancel")
{
    MultiView1.ActiveViewIndex = 1;
}

解决方案

You can check the result of the confirm and then close the window if true.

<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>

这篇关于管理LinkBut​​ton的使用Javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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