Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi freinds!
plz help me to solve my problem.i added this j query Tap too my asp.net web site .but when i put a datalist in this tap,I cannot see the datalist.it seems that, the Tab disaapear my datalist.Why?who can help me?

this is my code :
ASP.NET
<ul id="tabs">
       <li><a href="#" title="tab1">One</a></li>
       <li><a href="#" title="tab2">Two</a></li>
   </ul>
   <div id="content">
       <div id="tab1">
           <asp:DataList ID="DataList1" runat="server">
           </asp:DataList>
       </div>
       <div id="tab2">
       </div>
   </div>

   <script src="http://code.jquery.com/jquery-1.6.3.min.js"></script>

   <script>
       $(document).ready(function() {
           $("#content div").hide();
           $("#tabs li:first").attr("id", "current");
           $("#content div:first").fadeIn();

           $('#tabs a').click(function(e) {
               e.preventDefault();
               $("#content div").hide();
               $("#tabs li").attr("id", "");
               $(this).parent().attr("id", "current");
               $('#' + $(this).attr('title')).fadeIn();
           });
       })();

   </script>
Posted

Its working fine.. May be problem with your datalist(no data). Verify it correctly.

Try below...

XML
<style type="text/css">
        #tabs li
        {
            list-style: none;
            padding: 2px 10px;
            border: solid 1px silver;
            display: inline;
        }
        #content div
        {
            border: solid 1px silver;
        }
    </style>

    <script src="http://code.jquery.com/jquery-1.6.3.min.js"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            $("#content div").hide();
            $("#tabs li:first").attr("id", "current");
            $("#content div:first").fadeIn();

            $('#tabs a').click(function(e) {
                e.preventDefault();
                $("#content div").hide();
                $("#tabs li").attr("id", "");
                $(this).parent().attr("id", "current");
                $('#' + $(this).attr('title')).fadeIn();
            });
        })();

    </script>


XML
<ul id="tabs">
            <li><a href="#" title="tab1">One</a></li>
            <li><a href="#" title="tab2">Two</a></li>
        </ul>
        <div id="content">
            <div id="tab1">
                <asp:DataList ID="DataList2" runat="server" GridLines="Both" DataKeyField="slno"
                    DataSourceID="SqlDataSource1" RepeatColumns="5">
                    <ItemTemplate>
                        slno:
                        <asp:Label ID="slnoLabel" runat="server" Text='<%# Eval("slno") %>' />
                        <br />
                        planname:
                        <asp:Label ID="plannameLabel" runat="server" Text='<%# Eval("planname") %>' />
                        <br />
                        price:
                        <asp:Label ID="priceLabel" runat="server" Text='<%# Eval("price") %>' />
                        <br />
                    </ItemTemplate>
                </asp:DataList>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:constr %>"
                    SelectCommand="SELECT [slno], [planname], [price], [plantype], [advancerental], [monthlyrental] FROM [mobile_datacardplans]">
                </asp:SqlDataSource>
                Tab 1 body
            </div>
            <div id="tab2">
                Tab 2 body
            </div>
        </div>


Hope it works...
 
Share this answer
 
Comments
mina mini 7-Feb-13 6:13am    
thanks
the datalist appears!
:)
vinodkumarnie 7-Feb-13 6:56am    
welcome..
It's hard to understand your thinking, but you are using id selectors incorrectly. Please see:
http://api.jquery.com/id-selector/[^].

You should understand that the values of the id attributes are unique. So, not only you cannot combine then with element tags, but using just the id is just fine $("#DataList1"), $("#tab1"), etc. If you need something else, some selectors returning collections of items, you should use other selectors:
http://api.jquery.com/category/selectors/[^].

From the same considerations, it's hard to understand why do you try to modify id attributes with .attr("id", ...). If you break the uniqueness, the results can be unpredictable.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900