Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual Studio.NET trouble instantiating CssClass

Status
Not open for further replies.

christheprogrammer

Programmer
Jul 10, 2000
258
CA
Hi everyone,

I am trying to set the CssClass property of the TreeView Webcontrol. I have created a new Style Sheet, and place the following code inside:

.treeNodeStyle
{
background:#dcdcdc;
color:green;
font-size:12pt;
font-family:Arial;
}

Now, how the heck do I use this Style Sheet to format my Treeview control? I have tried the obvious, setting the CssClass property of the control to be .treeNodeStyle, treeNodeStyle, or TreeNodeStyle.css. I have also included the following line in <HEAD> section of the page the treeview control is on:

<LINK href=&quot;TreeNodeStyle.css&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot;>

And nothing is working.... Do I have to paste the Style Sheet code directly as the CssClass property? This seems ridiculous if it is the case.....

Cheers and thanks a million :) Chris
 
Hi Chris,

I'm not familiar with vb.net and the treeview webcontrol, but this is the way you add an stylesheet class to an HTML-tag (for example <p>:

--------code in yourCSSfile.css---------
.treeNodeStyle
{
background:#dcdcdc;
color:green;
font-size:12pt;
font-family:Arial;
}
----------------------------------------

<html>
<head>
<LINK href=&quot;yourCSSfile.css&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot;>
</head>
<body>
<p class=&quot;treeNodeStyle&quot;>
</body>
</html>

Hope this helps,
Erik
<!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
You can use the following properties in the vb codebhind file on page_load method as follows..

TreeView1.DefaultStyle = "BACKGROUND:#8095C4; MARGIN: 1px; PADDING: 1px; FONT-SIZE: 10pt; COLOR: WHITE; FONT-FAMILY: Verdana"

TreeView1.SelectedStyle = "BACKGROUND:#2c4d9c; MARGIN: 1px; PADDING: 1px; BORDER:#2C4D9C 1px SOLID; FONT-SIZE: 10pt; FONT-WEIGHT: bold; COLOR: WHITE; FONT-FAMILY: Verdana"

TreeView1.HoverStyle = "WIDTH: 100%;FONT-SIZE: 10pt;BACKGROUND-COLOR: #2c4d9c;"

It works for me..!

Thanks,
Srikanth
 
Or you could add CssClass="treeNodeStyle" in the asp: tag

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top