Results 1 to 27 of 27

Thread: Using jquery in a user control

Threaded View

  1. #1

    Thread Starter
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Using jquery in a user control

    Hi,

    I am trying to get some jquery to run but I have a feeling it is not working like the tutorial because I am wanting to run it in a user control rather than on the page.

    This is the code for the control jquery

    Code:
    <&#37;@ Control Language="C#" AutoEventWireup="true" CodeFile="SearchOutlines_j.ascx.cs" Inherits="usercontrols_SearchOutlines_j" %>
    <%@ Register TagPrefix="A" TagName="HelpIcon" Src="~/usercontrols/HelpIcon.ascx" %>
           <script src="../../scripts/jquery-1.5.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () 
        {
            $(".detail").hide();
    
            $(".header").click(function () 
            {
                $(this).next(".detail").slideToggle(300);
            });
        });
    </script>
    and here is the code with the divs i am wanting to show/hide

    Code:
     <div id="listing-container" class="listing-container">
                         
                        
                               <asp:Repeater ID="Repeater1" runat="server"
                                   onitemcommand="Repeater1_ItemCommand">
                                   <HeaderTemplate>
                                  <table class="coursetable1" border="0" cellpadding="0" cellspacing="0"> <tr><th class="leftcol" scope="col">TITLE</th><th scope="col">TYPE</th><th scope="col">CODE</th><th scope="col">DAYS</th></tr></HeaderTemplate>
                                   <ItemTemplate>
                                   <tr><td class="leftcol"><asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl="~/Outlines/Outlines.aspx" oncommand="CourseCodeClick" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Code")%>'><%# DataBinder.Eval(Container.DataItem, "Description")%></asp:LinkButton></td>
                                   <td><img alt='<%# DataBinder.Eval(Container.DataItem, "Type")%> Course' title='<%# DataBinder.Eval(Container.DataItem, "Type")%> Course' src='../Outlines/images/<%# DataBinder.Eval(Container.DataItem, "Type")%>.jpg' /></td>
                                   <td><%# DataBinder.Eval(Container.DataItem, "Code")%></td>
                                   <td><%# DataBinder.Eval(Container.DataItem, "Duration")%></td>
                                   <td><div id="header">Detail</div></td></tr>
                                   <tr><td><div id="detail">fish</div></td></tr>
                                   </ItemTemplate>
                                   <AlternatingItemTemplate>
                                   <tr class="altrow"><td class="leftcol"><asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl="~/Outlines/Outlines.aspx" oncommand="CodeClick" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Code")%>'><%# DataBinder.Eval(Container.DataItem, "Description")%></asp:LinkButton></td>
                                   <td><img alt='<%# DataBinder.Eval(Container.DataItem, "CourseType")%> ' title='<%# DataBinder.Eval(Container.DataItem, "CourseType")%> ' src='../Outlines/images/<%# DataBinder.Eval(Container.DataItem, "Type")%>.jpg' /></td>
                                   <td><%# DataBinder.Eval(Container.DataItem, "Code")%></td>
                                   <td><%# DataBinder.Eval(Container.DataItem, "Duration")%></td></tr>
                                                         </AlternatingItemTemplate>
                                    <FooterTemplate>
    	   </table>
       </FooterTemplate>
    
                               </asp:Repeater>
    
                            
    
                   
                        </div>
    Has anyone any experience of jquery in user controls on bound items?

    EDIT:

    I have also added the code

    <div id="courseheader">fish</div>
    <div id="coursedetail">chips</div>

    directly after the script tags. The chips also do not get hidden so the problem definately stems from it being a user control and not because of the repeater. I am also using master pages which could be affecting it!
    Last edited by FishGuy; Feb 23rd, 2011 at 11:55 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width