Javascript 无法从服务器端禁用jquery
我对jQuery有一些小问题,我想禁用这个jQuery,我尝试过任何方法,比如禁用服务器端的use tag DIV和PANEL,但不起作用,这是我要禁用的jQuery:Javascript 无法从服务器端禁用jquery,javascript,jquery,asp.net,Javascript,Jquery,Asp.net,我对jQuery有一些小问题,我想禁用这个jQuery,我尝试过任何方法,比如禁用服务器端的use tag DIV和PANEL,但不起作用,这是我要禁用的jQuery: //To show or hide button select $("[ID*=DivText]").click(function() { $(this).next("[ID*=DivImgSelect]").css("display", "block"); $(this).prevAll("[ID*=hdnFoote
//To show or hide button select
$("[ID*=DivText]").click(function() {
$(this).next("[ID*=DivImgSelect]").css("display", "block");
$(this).prevAll("[ID*=hdnFooter]").val("True");
$(this).prevAll("[ID*=hdnText]").val("True");
$(this).css("display", "none");
});
$("[ID*=DivImgSelect]").click(function() {
$(this).prevAll("[ID*=DivText]").css("display", "block");
$(this).prevAll("[ID*=hdnFooter]").val("False");
$(this).prevAll("[ID*=hdnText]").val("False");
$(this).css("display", "none");
});
这是我使用jquery时的标记asp:
<ItemTemplate>
<asp:Panel ID="DisplayFlags" runat="server" Enabled ="true">
<div id="DivTextInbox" runat="server" class="outerDiv" style='<%# DataBinder.Eval(Container.DataItem, "InboxFlag").ToString()=="True" ? "display:none": "display:block" %>'>
<a class="LinkText">
<asp:Label ID="spanLinkInbox" CssClass="LinkText" Style="cursor: pointer" ForeColor="blue" runat="server" Text="Not Allowed "></asp:Label></a>
</div>
<div id="DivImgSelectInbox" runat="server" class="imageSelected" style='<%# DataBinder.Eval(Container.DataItem, "InboxFlag").ToString()=="True" ? "display:block": "display:none" %>'>
<asp:Image runat="server" ID="imgSelectInbox" ImageUrl="~/Images/check.png" Width="16px"
Style="cursor: pointer" />
</div>
</asp:Panel>
</ItemTemplate>
利用下面的代码,我想你会得到答案的
$("[ID*=DivImgSelect]").off('click');
要在后端使用它,只需按以下方式使用
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script",
"<script type='text/javascript'>$('[ID*=DivImgSelect]').off('click');
</script>", false);
ScriptManager.RegisterStartupScript(this.Page,this.GetType(),“script”,
“$('[ID*=DivImgSelect]')。关闭('click');
“,假);
我没有试过,但是
您可以像这样从客户端解除绑定事件
$( "#foo" ).unbind();
但是我想你应该在服务器端注册这个脚本
像这样的
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>youcode here</script>", false);
ScriptManager.RegisterStartupScript(this.Page,this.GetType(),“tmp”,“youcode here”,false);
禁用??你为什么不删除代码呢?顺便说一句,你的问题不清楚。是否删除代码?我用过的代码,当处于条件启用状态时我用过,否则当禁用条件时我不使用,,,我希望是clearly@user3606622您可以使用只读,也可以删除DivImgSelect
的clickevent这是最简单的one@TheDictator不,我如何删除服务器端divImgselect的clickevent?因为我不知道dude?嗯,我是如何在服务器端实现代码的?你能帮我吗伙计@TheDictator:))你对我做了同样的事,看到更新的答案。。。你也可以使用bind()/unbind(),这也是下面给出的答案…@sakir bro他不知道这就是我需要更新答案的原因。。这是他唯一能做到的…谢谢dude@sakir,谢谢你的帮助,它起作用了。。。谢谢你,所以我的JQuery代码放在了ScriptManager.RegisterStartupScript上(this.Page,this.GetType(),“tmp”,“youcode here”,false);不是吗?他已经清楚地提到了youcode这里
。。现在你只需要把你的代码放在那里