Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 12, 2009 05:57 AM by mudassarkhan
Member
107 Points
32 Posts
Feb 08, 2009 04:31 PM|LINK
I am using these nested DataLists for Left navigation of my site:
<div class="LeftNav"> <asp:DataList ID="dtlstMainMenu" RepeatLayout="Flow" runat="server" HorizontalAlign="Left" RepeatColumns="1" OnItemDataBound="dtlstMainMenu_ItemDataBound" DataKeyField="CategoryID"> <ItemTemplate> <div class="mainproducts"> <asp:Literal ID="ltrlMainHead" Visible="false" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CategoryName")%>'></asp:Literal></u> </div> <asp:DataList ID="dtlstSubMenu" RepeatLayout="Flow" runat="server" HorizontalAlign="Right" RepeatColumns="1"> <ItemTemplate> <ul class="uolist"> <li class="listsfirst"><a class="listlink" href='/<%# mainCatetory.ToString()%>/<%# Eval("SubCategoryName").ToString() %>.aspx'> <%# DataBinder.Eval(Container.DataItem, "SubCategoryName")%> </a></li> </ul> </ItemTemplate> </asp:DataList> </ItemTemplate> </asp:DataList> </div>
The Generated Html looks like this:
<div class="LeftNav"> <span id="ctl00_dtlstMainMenu"><span> <div class="mainproducts"> Apparel</u> </div> <span id="ctl00_dtlstMainMenu_ctl00_dtlstSubMenu"><span> <ul class="uolist"> <li class="listsfirst"><a class="listlink" href='/Apparel/Mens-Apparels.aspx?CurrentPage=1'> Mens Apparels </a></li> </ul> </span><br /><span> <ul class="uolist"> <li class="listsfirst"><a class="listlink" href='/Apparel/Kids-Toys.aspx?CurrentPage=1'> Kids Toys </a></li> </ul> </span></span> </span><br /><span> <div class="mainproducts"> Electronics</u> </div> <span id="ctl00_dtlstMainMenu_ctl01_dtlstSubMenu"><span> <ul class="uolist"> <li class="listsfirst"><a class="listlink" href='/Electronics/Computers.aspx?CurrentPage=1'> Computers </a></li> </ul> </span></span> </span></span> </div>
DataList generates HTML with many span tags.
I want to remove these span tags, how can i remove these? I don't want to use table layout.
any help will be appreciated.
Remove <Span> tags from Datalist Generated HTML
All-Star
113532 Points
12480 Posts
Microsoft
Feb 12, 2009 02:55 AM|LINK
Hi web.dev,
I have done searching a lot, but unfortunately, I cannot find the solution for remove <span>. You can try to set RepeatDirection="Horizontal" and RepeatLayout="Flow" in DataList in order not to use table layout and remove auto <br> on page.
Thanks,
Contributor
5747 Points
1111 Posts
Feb 12, 2009 05:46 AM|LINK
Hi We.Dev
I m not sure about your solution but have you tried to change the RepeaterLayout from "Flow" to "Table" ?
78956 Points
13402 Posts
MVP
Feb 12, 2009 05:57 AM|LINK
Its is the property of the control all ASP controls get converted into one or other html controls so you cannot control that.
For eg Gridview gets converted to table
Label to span
RadioButton list a table with Radiobuttons
and so on
web.dev
Member
107 Points
32 Posts
Remove <Span> tags from Datalist Generated HTML
Feb 08, 2009 04:31 PM|LINK
I am using these nested DataLists for Left navigation of my site:
<div class="LeftNav">
<asp:DataList ID="dtlstMainMenu" RepeatLayout="Flow" runat="server" HorizontalAlign="Left"
RepeatColumns="1" OnItemDataBound="dtlstMainMenu_ItemDataBound" DataKeyField="CategoryID">
<ItemTemplate>
<div class="mainproducts">
<asp:Literal ID="ltrlMainHead" Visible="false" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CategoryName")%>'></asp:Literal></u>
</div>
<asp:DataList ID="dtlstSubMenu" RepeatLayout="Flow" runat="server" HorizontalAlign="Right"
RepeatColumns="1">
<ItemTemplate>
<ul class="uolist">
<li class="listsfirst"><a class="listlink" href='/<%# mainCatetory.ToString()%>/<%# Eval("SubCategoryName").ToString() %>.aspx'>
<%# DataBinder.Eval(Container.DataItem, "SubCategoryName")%>
</a></li>
</ul>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>
</div>
The Generated Html looks like this:
<div class="LeftNav">
<span id="ctl00_dtlstMainMenu"><span>
<div class="mainproducts">
Apparel</u>
</div>
<span id="ctl00_dtlstMainMenu_ctl00_dtlstSubMenu"><span>
<ul class="uolist">
<li class="listsfirst"><a class="listlink" href='/Apparel/Mens-Apparels.aspx?CurrentPage=1'>
Mens Apparels
</a></li>
</ul>
</span><br /><span>
<ul class="uolist">
<li class="listsfirst"><a class="listlink" href='/Apparel/Kids-Toys.aspx?CurrentPage=1'>
Kids Toys
</a></li>
</ul>
</span></span>
</span><br /><span>
<div class="mainproducts">
Electronics</u>
</div>
<span id="ctl00_dtlstMainMenu_ctl01_dtlstSubMenu"><span>
<ul class="uolist">
<li class="listsfirst"><a class="listlink" href='/Electronics/Computers.aspx?CurrentPage=1'>
Computers
</a></li>
</ul>
</span></span>
</span></span>
</div>
DataList generates HTML with many span tags.
I want to remove these span tags, how can i remove these? I don't want to use table layout.
any help will be appreciated.
Remove <Span> tags from Datalist Generated HTML
----
web.dev
Please remember to click "Mark as Answer" on the post(s) which helps you !
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: Remove <Span> tags from Datalist Generated HTML
Feb 12, 2009 02:55 AM|LINK
Hi web.dev,
I have done searching a lot, but unfortunately, I cannot find the solution for remove <span>. You can try to set RepeatDirection="Horizontal" and RepeatLayout="Flow" in DataList in order not to use table layout and remove auto <br> on page.
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework
Pushkar
Contributor
5747 Points
1111 Posts
Re: Remove <Span> tags from Datalist Generated HTML
Feb 12, 2009 05:46 AM|LINK
Hi We.Dev
I m not sure about your solution but have you tried to change the RepeaterLayout from "Flow" to "Table" ?
====================================
Pushkar
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Remove <Span> tags from Datalist Generated HTML
Feb 12, 2009 05:57 AM|LINK
Its is the property of the control all ASP controls get converted into one or other html controls so you cannot control that.
For eg Gridview gets converted to table
Label to span
RadioButton list a table with Radiobuttons
and so on
Contact me