Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么在使用jquery隐藏元素时再次显示它_Jquery_Asp.net_Listview_Updatepanel_Linkbutton - Fatal编程技术网

为什么在使用jquery隐藏元素时再次显示它

为什么在使用jquery隐藏元素时再次显示它,jquery,asp.net,listview,updatepanel,linkbutton,Jquery,Asp.net,Listview,Updatepanel,Linkbutton,我在网页中有一个listview控件,在listview中有一个LinkButton。updatepanel控件中的我的链接按钮。当我点击LinkButton时,计数器字段+1。我使用clientdmode=“AutoID”表示我的页面未完成后打包。现在,我想当点击LinkButton时,LinkButton的显示等于“无”。为此,我使用以下脚本: <script type="text/javascript"> function updateTextArea() { $('.

我在网页中有一个listview控件,在listview中有一个LinkButton。updatepanel控件中的我的链接按钮。当我点击LinkButton时,计数器字段+1。我使用clientdmode=“AutoID”表示我的页面未完成后打包。现在,我想当点击LinkButton时,LinkButton的显示等于“无”。为此,我使用以下脚本:

<script type="text/javascript">
function updateTextArea() {
    $('.like').on('click', 'a', function () {
        $(this).hide();
    });
}

函数updateTextArea(){
$('.like')。在('click','a',函数(){
$(this.hide();
});
}


Sys.WebForms.PageRequestManager.getInstance().add_endRequest(updateTextArea);
现在,我的问题是:当我点击LinkButton时,LinkButton被再次隐藏和显示。哪里是我的错。请帮帮我。非常感谢

这是我的aspx代码:

<asp:ListView ID="PortfolioListView" runat="server" onitemcommand="PortfolioListView_ItemCommand">
                <ItemTemplate>
                    <li class="item brick1 <%# Eval("CategoryName")%> isotope-item">
                        <a class="item-popup" href="Gallery/195x195/<%# Eval("MainImage") %>" title="<%# Eval("ShortDesc") %>">
                            <img src="Gallery/195x195/<%# Eval("MainImage") %>" alt="<%# Eval("Title") %>" />
                            <div class="hover">
                                <span class="Popup"><i class="fa fa-search-plus"></i></span>
                                <span><%# Eval("CategoryName")%></span>
                            </div>
                        </a>
                        <div class="bottom">
                            <div class="title"><span><%# Eval("Title")%></span></div>
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate>
                            <div class="like"><asp:LinkButton ID="LikeLBTN" runat="server" ClientIDMode="AutoID" OnClientClick="updateTextArea()" CommandName="Like" CommandArgument="<%# Bind('GalleryID') %>"><i class="fa fa-thumbs-o-up"></i><span><%# Eval("Counter")%></span></asp:LinkButton></div>
                            </ContentTemplate></asp:UpdatePanel>
                        </div>
                    </li>
                </ItemTemplate>
            </asp:ListView>



这是由于asp.net控件的自动发布功能造成的。更新java脚本函数后,其余代码将与此相同

function updateTextArea() {
        $('.like').on('click', 'a', function () {
            $(this).hide();
            return false;
        });
    }

当您检查元素并查看时,会发生什么情况?
是否显示:无存在或被覆盖或其他?当我单击链接按钮时,显示:无添加到标记,然后它将被删除。
它将被删除
-为什么?谁在哪里?在OnClientClick中添加一个return false,以避免使用return false进行回发
,LinkButton被隐藏,不再显示。这是好的,但当我点击linkbutton时,是否应该将一个添加到like的数量(计数器字段)。在数据库中保存的like数,在listview中使用CommandName=“like”,我更新此字段。当我在脚本中使用returnfalse时,代码隐藏中的update命令不起作用。还有别的解决办法吗?如果是这种情况,则使用aspx.cs文件来处理隐藏或其他事件
function updateTextArea() {
        $('.like').on('click', 'a', function () {
            $(this).hide();
            return false;
        });
    }