显示使用jquery在转发器中隐藏单个图像 [英] Show hide a single image in repeater using jquery

查看:55
本文介绍了显示使用jquery在转发器中隐藏单个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个转发器控件,如下所示,当用户选择除默认选择值以外的任何其他值时,我想显示图像按钮。

Hello all,
I have a repeater control as below, and I want to show the image button when users selected any other values other than the default Select value.

<asp:Repeater ID="rptSearchUser" runat="server">
                    <HeaderTemplate>
                        <h4>
                            Add Users</h4>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <div class="posSharingUsrList">
                            <div class="pull-left">
                                <asp:Label ID="lblUsername" runat="server" Text='<%#Eval("USER_NAME") %>'></asp:Label>
                            </div>
                            <div class="pull-left selectDiv">
                                <asp:DropDownList ID="ddlUserRoles" runat="server">
                                    <asp:ListItem Value="0">Select Role</asp:ListItem>
                                    <asp:ListItem>Full Control</asp:ListItem>
                                    <asp:ListItem>View only</asp:ListItem>
                                </asp:DropDownList>
                            </div>
                            <div class="pull-right">
                                <asp:ImageButton ID="iBtnShareWithUser" runat="server" CommandArgument='<%#Eval("EMP_ID")%>'

                                    ImageUrl="~/Images/GreenCircle.png" OnClick="iBtnShareWithUser_Click" CssClass="imgPlus" />
                            </div>
                            <div class="clearfix">
                            </div>
                        </div>
                    </ItemTemplate>
                </asp:Repeater>



我已经尝试了以下jQuery代码来显示和隐藏图像按钮,但问题是,如果我们从下拉列表中选择一个项目,如果转发器重复多个项目,将显示所有图像。




I have tried the following jQuery code to show and hide the image button, but the problem is, if we selected an item from dropdown list, all of the images will display, if the repeater repeats more than one item.

$(function () {
            $("[id$='ddlUserRoles']").change(function () {
                if (this.value !== "0") {
                    $("[id$='iBtnShareWithUser']").show();
                } else {
                    $("[id$='iBtnShareWithUser']").hide();
                }
            });
        });





我试图用它的类取代Image按钮id,但没有运气。如何在不使用autopostback事件的情况下实现此功能?因为,我在Bootstrap Modal Popup中使用这个转发器控件。如果需要测试,我已经创建了一个 jsbin



谢谢。



I tried to replace the Image button id with its class, but no luck. How I can get this worked without using autopostback event? Because, I''m using this repeater control inside Bootstrap Modal Popup. I have created a jsbin, if needed for testing.

Thanks.

推荐答案

function (){


[id
("[id


='ddlUserRoles'])。change( function (){
if this .value!== 0){
='ddlUserRoles']").change(function () { if (this.value !== "0") {


这篇关于显示使用jquery在转发器中隐藏单个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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