tags:

views:

25

answers:

1

I am using ListView and i want to find the LinkButton using JQuery how is it possible

<asp:ListView ID="dlSearchListView" runat="server" >
            <LayoutTemplate>
                <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
            </LayoutTemplate>
            <ItemTemplate>
<div class="right">
                            <div class="space1">
                                <asp:LinkButton ID="lnkbtnTell_a_Friend" runat="server" Text="Tell a Friend" CssClass="PropertyLinkButtons"></asp:LinkButton>
                            </div>
                            <div class="space1">
                                <asp:LinkButton ID="lnkbtnEmail_Owner" runat="server" Text="Email Owner" CssClass="PropertyLinkButtons"></asp:LinkButton>
                            </div>
                            <div class="space1">
                                <asp:LinkButton ID="lnkView" runat="server" Text="View" CommandName="View" CssClass="PropertyLinkButtons"></asp:LinkButton>
                            </div>
                        </div>
</div>
            </ItemTemplate>
        </asp:ListView>

Now how can i find the link button "lnkbtnTell_a_Friend" using Jquery

Thanks in advance Vara Prasad.M

+1  A: 

The simplest/cleanest way is to give it an additional class, just change it's CssClass like this:

CssClass="PropertyLinkButtons FriendButton"

then in jQuery use a .class selector:

$(".FriendButton").doSomething();

Otherwise you could find them by ID and an attribute-contains selector, but it's much slower:

$("a[id*='lnkbtnTell_a_Friend']").doSomething();
Nick Craver
actually the Listview is in user control and in the page i am not able to get the alert if i am finding the link button under the usercontrol in the page which the usercontrol is inheritedhow can i do this?
Vara Prasad.M
How do i find the Link button inside a list view if i place that link button in a listview under a user control and i am using the user control in a page then how do i find the link button either from page or in user control?
Vara Prasad.M
@Vara - Both of the above methods should work like this...the class method doesn't care where it's nested, it'll find it anywhere in the rendered markup. Are you trying to find the control in jQuery or in ASP.Net? I ask because that's an *entirely* different question.
Nick Craver
i have to get the link button in aspx page using jquery means i have to write under script and identify that
Vara Prasad.M
How to get the link button in the page using jquery can i have this as soon as possible
Vara Prasad.M
means we cannnot find the link button inside the list view when the list view is placed in user control and from the page we cannot access the link button using jquery????
Vara Prasad.M