473,657 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="rightNav Highlight"><a href="#">Ergono mics</a></div>
<div class="rightNav Highlight"><a href="#">Enviro nmental
Responsibility</a></div>
<div class="rightNav Highlight"><a href="#">Workpl ace Trends</a></div>
<div class="rightNav Highlight"><a href="#">Typica ls Gallery</a></div>
<div class="rightNav Highlight"><a href="#">Image Gallery</a></div>
<div class="rightNav Highlight"><a href="#">Projec t Profiles</a></div>
<div class="rightNav HighlightAct">< a href="#">Case Studies</a></div>
<div class="rightNav Highlight"><a href="#">Real Life Stories</a></div>
<div class="rightNav Highlight"><a href="#">White Papers</a></div>
<div class="rightNav Highlight"><a href="#">Produc t Solution Center</a></div>
<div class="rightNav Highlight"><a href="#">Produc t Document Library</a></div>

Thanks for the help.

--
James Coleman
Technical Director
AGENCY.COM [Chicago]
Apr 19 '06 #1
1 2451
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 SiteMapDataSour ce. I loop through the SiteMapDataSour ce 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(objec t sender, EventArgs e)
{
litRightNav.Tex t =
string.Format(" {0}",DisplaySit eMapLevelAsBull etedList());
}

private string DisplaySiteMapL evelAsBulletedL ist()
{
SiteMapDataSour ceView siteMapView =
((SiteMapDataSo urceView)(SiteM apData.GetView( string.Empty))) ;
SiteMapNodeColl ection nodes =
((SiteMapNodeCo llection)(siteM apView.Select(D ataSourceSelect Arguments.Empty )));
return GetSiteMapLevel AsBulletedList( nodes,false);
}

private string GetSiteMapLevel AsBulletedList( SiteMapNodeColl ection
nodes, bool indent)
{
string output = string.Empty;
string cssClass = "rightNavHighli ght";
string cssClassSelecte d = "rightNavHighli ghtAct";
string div = "<div class=\"rightNa vHighlight\">";
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("ri ghtNavHighlight ",
"rightNavHighli ghtAct");
}
else
{
div = div.Replace("Ac t", "");
}
getChildren = (currentPath.In dexOf(node.Url) > -1 && indent ==
false);
output += string.Format(d iv + "<a href=\"{0}\">{1 }</a></div>",
node.Url, node.Title);

if (node.HasChildN odes && getChildren && (indent==false) )
{
output += string.Format(" {0}",
GetSiteMapLevel AsBulletedList( 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="rightNav Highlight"><a href="#">Ergono mics</a></div>
<div class="rightNav Highlight"><a href="#">Enviro nmental
Responsibility</a></div>
<div class="rightNav Highlight"><a href="#">Workpl ace Trends</a></div>
<div class="rightNav Highlight"><a href="#">Typica ls Gallery</a></div>
<div class="rightNav Highlight"><a href="#">Image Gallery</a></div>
<div class="rightNav Highlight"><a href="#">Projec t Profiles</a></div>
<div class="rightNav HighlightAct">< a href="#">Case Studies</a></div>
<div class="rightNav Highlight"><a href="#">Real Life Stories</a></div>
<div class="rightNav Highlight"><a href="#">White Papers</a></div>
<div class="rightNav Highlight"><a href="#">Produc t Solution Center</a></div>
<div class="rightNav Highlight"><a href="#">Produc t 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
2501
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> <div> <span>
8
4660
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 this would work but I get this error: "End tag 'xsl:if' does not match the start tag 'ul'." Any thoughts?
3
84599
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
24463
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 'stretch'</td> <td valign="top" width="300">some data that won't 'stetch'</td> </tr> </table>
19
17428
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 spacing? Thanks, CMA <div class="vlgray">Condition</div> <table cellpadding="0" cellspacing="0">
10
26096
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 null references another, FK_LASTLYOID bigint not null references lastly, unique (FK_OTHEROID,FK_ANOTHEROID))
0
1306
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
4835
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
1842
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 change to a control my whole table gets resized and screwed up from some reason. I may have a column with a width of 75px, but it will appear so narrow it is hardly visible. Anyway, in these cases I undo what made this happen and the table fixes...
0
8403
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8316
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.