473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Treeview Controls without a <table>

I am using the TreeView control in ASP.NET 2.0 and like it. However, our
sitebuilders aren't too pleased with the idea of the table that gets
rendered. They are big into avoiding <table> tags when it comes to site
build.

So is there a way I could have the following html be rendered from the
treeview control?

<div class="rightNavHighlight"><a href="#">Ergonomics</a></div>
<div class="rightNavHighlight"><a href="#">Environmental
Responsibility</a></div>
<div class="rightNavHighlight"><a href="#">Workplace Trends</a></div>
<div class="rightNavHighlight"><a href="#">Typicals Gallery</a></div>
<div class="rightNavHighlight"><a href="#">Image Gallery</a></div>
<div class="rightNavHighlight"><a href="#">Project Profiles</a></div>
<div class="rightNavHighlightAct"><a href="#">Case Studies</a></div>
<div class="rightNavHighlight"><a href="#">Real Life Stories</a></div>
<div class="rightNavHighlight"><a href="#">White Papers</a></div>
<div class="rightNavHighlight"><a href="#">Product Solution Center</a></div>
<div class="rightNavHighlight"><a href="#">Product Document Library</a></div>

Thanks for the help.

--
James Coleman
Technical Director
AGENCY.COM [Chicago]
Apr 19 '06 #1
1 2437
Well, I just avoided the Treeview control completely. I figured I would post
my solution, in case someone else has a similar issue. Bascially I have a
literal and a SiteMapDataSource. I loop through the SiteMapDataSource Nodes
and build the <div> tags dynamically. I could have used a repeater instead
of a literal but I needed to have the node only expanded if it was the parent
of the selected node and collapsed if it is not.

protected void Page_Load(object sender, EventArgs e)
{
litRightNav.Text =
string.Format("{0}",DisplaySiteMapLevelAsBulletedL ist());
}

private string DisplaySiteMapLevelAsBulletedList()
{
SiteMapDataSourceView siteMapView =
((SiteMapDataSourceView)(SiteMapData.GetView(strin g.Empty)));
SiteMapNodeCollection nodes =
((SiteMapNodeCollection)(siteMapView.Select(DataSo urceSelectArguments.Empty)));
return GetSiteMapLevelAsBulletedList(nodes,false);
}

private string GetSiteMapLevelAsBulletedList(SiteMapNodeCollectio n
nodes, bool indent)
{
string output = string.Empty;
string cssClass = "rightNavHighlight";
string cssClassSelected = "rightNavHighlightAct";
string div = "<div class=\"rightNavHighlight\">";
bool getChildren;
string currentPath = CmsHttpContext.Current.Posting.Path;
string currentPosting = CmsHttpContext.Current.Posting.DisplayName;
if (indent)
{
div = div.Replace("\">", " marginLeft10px\">");
}
foreach (SiteMapNode node in nodes)
{
if (currentPosting == node.Title)
{
div = div.Replace("rightNavHighlight",
"rightNavHighlightAct");
}
else
{
div = div.Replace("Act", "");
}
getChildren = (currentPath.IndexOf(node.Url) > -1 && indent ==
false);
output += string.Format(div + "<a href=\"{0}\">{1}</a></div>",
node.Url, node.Title);

if (node.HasChildNodes && getChildren && (indent==false))
{
output += string.Format("{0}",
GetSiteMapLevelAsBulletedList(node.ChildNodes,true ));
}
}
return output;
}

--
James Coleman
Technical Director
AGENCY.COM [Chicago]
"James Coleman" wrote:
I am using the TreeView control in ASP.NET 2.0 and like it. However, our
sitebuilders aren't too pleased with the idea of the table that gets
rendered. They are big into avoiding <table> tags when it comes to site
build.

So is there a way I could have the following html be rendered from the
treeview control?

<div class="rightNavHighlight"><a href="#">Ergonomics</a></div>
<div class="rightNavHighlight"><a href="#">Environmental
Responsibility</a></div>
<div class="rightNavHighlight"><a href="#">Workplace Trends</a></div>
<div class="rightNavHighlight"><a href="#">Typicals Gallery</a></div>
<div class="rightNavHighlight"><a href="#">Image Gallery</a></div>
<div class="rightNavHighlight"><a href="#">Project Profiles</a></div>
<div class="rightNavHighlightAct"><a href="#">Case Studies</a></div>
<div class="rightNavHighlight"><a href="#">Real Life Stories</a></div>
<div class="rightNavHighlight"><a href="#">White Papers</a></div>
<div class="rightNavHighlight"><a href="#">Product Solution Center</a></div>
<div class="rightNavHighlight"><a href="#">Product Document Library</a></div>

Thanks for the help.

--
James Coleman
Technical Director
AGENCY.COM [Chicago]

Apr 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Philo | last post by:
How do I select all <div> tags except those which contain a <table> tag somewhere within them? Example XML: <********************** sample input ***********************> <txtSectionBody>...
8
by: bearclaws | last post by:
I am looping through a list of categories and want to display the list horizontally (instead of vertically). I want to create a single row with 4 list items in each cell of the row. I thought...
3
by: Paul Thompson | last post by:
When I put a <div ...> inside a <table> specification, functionality is not there. When I put the <table> inside the <div> everything works. Why is that?
61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
19
by: CMAR | last post by:
I have the following markup. The problem is that the browser, e.g., IE6, inserts several lines of blank space between the <div> and the following table. Is there a way to minimize that vertical...
10
by: BuddhaBuddy | last post by:
Platform is DB2/NT 7.2.9 The table was created like this: CREATE TABLE MYTEST ( MYTESTOID bigint not null primary key, FK_OTHEROID bigint not null references other, FK_ANOTHEROID bigint not...
0
by: timnels | last post by:
I've got a bizzare issue where I have an XML file to load into a data set like: <conversion> <table name="parent"> <table name="child"> </table> </table> <table name="another parent"> ....
2
by: Frank van Vugt | last post by:
Hi, Not exactly a showstopper, but I noticed this behaviour: db=# create table f1 (id int, value int); CREATE TABLE db=# insert into f1 select 1 as id, null; INSERT 25456306 1
0
by: =?Utf-8?B?R3JlZw==?= | last post by:
I've created my table and alli is fine. I name my <tdtags to make them easier to identify when my table gets large. Anyway, I am naming as such: <td id="cellName" > Now, sometimes when make a...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.