<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Custom Server Controls</title><link>http://forums.asp.net/19.aspx</link><description>All about building ASP.NET server controls. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=12&amp;c=17" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: How to customize the styles on individual TreeNodes ?</title><link>http://forums.asp.net/thread/1159160.aspx</link><pubDate>Wed, 04 Jan 2006 21:49:39 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1159160</guid><dc:creator>srillaert</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1159160.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1159160</wfw:commentRss><description>Thanks Kris !&lt;br /&gt;&lt;br /&gt;seems that Fredrik Normén was really quick to post about this extensibility of TreeNodes.&lt;br /&gt;&lt;br /&gt;greetz, Stefaan&lt;br /&gt;</description></item><item><title>Re: How to customize the styles on individual TreeNodes ?</title><link>http://forums.asp.net/thread/1158960.aspx</link><pubDate>Wed, 04 Jan 2006 18:21:55 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1158960</guid><dc:creator>XIII</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1158960.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1158960</wfw:commentRss><description>&lt;p&gt;Hi Stefaan,&lt;/p&gt;
&lt;p&gt;I also found this blog that could be interesting for you: &lt;a href="http://fredrik.nsquared2.com/viewpost.aspx?PostID=299"&gt;http://fredrik.nsquared2.com/viewpost.aspx?PostID=299&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Grz, Kris.&lt;/p&gt;</description></item><item><title>Re: How to customize the styles on individual TreeNodes ?</title><link>http://forums.asp.net/thread/1154163.aspx</link><pubDate>Thu, 29 Dec 2005 10:43:14 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1154163</guid><dc:creator>srillaert</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1154163.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1154163</wfw:commentRss><description>Hello Danny,&lt;br /&gt;&lt;br /&gt;Thanks for taking your time to look at this. Your reply convinced me that this way of doing it should work and that it was something I was doing wrong. Your example was working so why wasn't mine ? And what a stupid mistake it was ! During my tests I was using :&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "&lt;font color="#ff0000"&gt;Grey&lt;/font&gt;")&lt;br /&gt;&lt;br /&gt;"Grey" is not an &lt;a href="http://www.w3schools.com/css/css_colornames.asp"&gt;official CCS color&lt;/a&gt; (and English is not my native language &lt;img src="/emoticons/emotion-1.gif" alt="Smile [:)]" /&gt;). This should have been :&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "&lt;font color="#ff0000"&gt;Gray&lt;/font&gt;")&lt;br /&gt;&lt;br /&gt;Normally I should have discovered this mistake early but the problem was that Firefox recognizes "Grey". And so the rendered html :&lt;br /&gt;&lt;br /&gt;&amp;lt;a class="TreeView2_0 TreeView2_1" href="javascript:__doPostBack('TreeView2','sroot')" onclick="TreeView_SelectNode(TreeView2_Data, this,'TreeView2t0');" id="TreeView2t0" style="background-color:green;&lt;font color="#ff0000"&gt;color:Grey;&lt;/font&gt;"&amp;gt;root&amp;lt;/a&amp;gt;&lt;br /&gt;&lt;br /&gt;changed the color of the TreeNode text in Firefox but not in IE which lead me to the wrong conclusion that in IE class="TreeView2_0 TreeView2_1" takes precedence over style="background-color:green;color:Grey;" and in Firefox it is the other way around. Totally wrong.&lt;br /&gt;&lt;br /&gt;So thanks a lot, I will continue working in this direction (with the suggestions you made). Have a great New Year and all the best wishes for 2006 !&lt;br /&gt;&lt;br /&gt;</description></item><item><title>Re: How to customize the styles on individual TreeNodes ?</title><link>http://forums.asp.net/thread/1153852.aspx</link><pubDate>Wed, 28 Dec 2005 23:38:40 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1153852</guid><dc:creator>dannychen</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1153852.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1153852</wfw:commentRss><description>&lt;p&gt;I'm not sure I follow you here.&amp;nbsp; Your code should work.&amp;nbsp; It's quite a good solution actually.&amp;nbsp; Here's the code I used to test this:&lt;/p&gt;
&lt;div&gt;&lt;font color=blue&gt;Namespace&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=blue&gt;My&lt;br /&gt;&lt;/font&gt;&lt;font color=black&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=blue&gt;Public&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=blue&gt;Class&lt;/font&gt;&lt;font color=black&gt; MyTreeNode&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=blue&gt;Inherits&lt;/font&gt;&lt;font color=black&gt; TreeNode&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=blue&gt;Protected&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=blue&gt;Overrides&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=blue&gt;Sub&lt;/font&gt;&lt;font color=black&gt; RenderPreText(&lt;/font&gt;&lt;font color=blue&gt;ByVal&lt;/font&gt;&lt;font color=black&gt; writer &lt;/font&gt;&lt;font color=blue&gt;As&lt;/font&gt;&lt;font color=black&gt; System.Web.UI.HtmlTextWriter)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, &lt;/font&gt;&lt;font color=maroon&gt;"green"&lt;/font&gt;&lt;font color=black&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;writer.AddStyleAttribute(HtmlTextWriterStyle.Color, &lt;/font&gt;&lt;font color=maroon&gt;"Red"&lt;/font&gt;&lt;font color=black&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=blue&gt;MyBase&lt;/font&gt;&lt;font color=black&gt;.RenderPreText(writer)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=blue&gt;End&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=blue&gt;Sub&lt;br /&gt;&lt;/font&gt;&lt;font color=black&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=blue&gt;End&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=blue&gt;Class&lt;br /&gt;End&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=blue&gt;Namespace&lt;/font&gt;&lt;/div&gt;
&lt;p&gt;&lt;font color=#000000&gt;And the page:&lt;/font&gt;&lt;/p&gt;&lt;font color=blue&gt;
&lt;div&gt;&lt;font color=blue&gt;&amp;lt;&lt;/font&gt;&lt;font color=maroon&gt;asp&lt;/font&gt;&lt;font color=blue&gt;:&lt;/font&gt;&lt;font color=maroon&gt;TreeView&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;ID&lt;/font&gt;&lt;font color=blue&gt;="TreeView1"&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;runat&lt;/font&gt;&lt;font color=blue&gt;="server"&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;font color=black&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=blue&gt;&amp;lt;&lt;/font&gt;&lt;font color=maroon&gt;Nodes&lt;/font&gt;&lt;font color=blue&gt;&amp;gt;&lt;/font&gt;&lt;font color=black&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=blue&gt;&amp;lt;&lt;/font&gt;&lt;font color=maroon&gt;My&lt;/font&gt;&lt;font color=blue&gt;:&lt;/font&gt;&lt;font color=maroon&gt;MyTreeNode&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;Text&lt;/font&gt;&lt;font color=blue&gt;="root"&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;Value&lt;/font&gt;&lt;font color=blue&gt;="root"&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;mystyle&lt;/font&gt;&lt;font color=blue&gt;="color: red;"&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;font color=black&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=blue&gt;&amp;lt;&lt;/font&gt;&lt;font color=maroon&gt;My&lt;/font&gt;&lt;font color=blue&gt;:&lt;/font&gt;&lt;font color=maroon&gt;MyTreeNode&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;Text&lt;/font&gt;&lt;font color=blue&gt;="child"&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;Value&lt;/font&gt;&lt;font color=blue&gt;="child"&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;mystyle&lt;/font&gt;&lt;font color=blue&gt;="color: green;"&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=blue&gt;/&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;font color=black&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=blue&gt;&amp;lt;/&lt;/font&gt;&lt;font color=maroon&gt;My&lt;/font&gt;&lt;font color=blue&gt;:&lt;/font&gt;&lt;font color=maroon&gt;MyTreeNode&lt;/font&gt;&lt;font color=blue&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;font color=black&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=blue&gt;&amp;lt;/&lt;/font&gt;&lt;font color=maroon&gt;Nodes&lt;/font&gt;&lt;font color=blue&gt;&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;font color=black&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=blue&gt;&amp;lt;&lt;/font&gt;&lt;font color=maroon&gt;NodeStyle&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;BackColor&lt;/font&gt;&lt;font color=blue&gt;="Black"&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;BorderColor&lt;/font&gt;&lt;font color=blue&gt;="Purple"&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;BorderWidth&lt;/font&gt;&lt;font color=blue&gt;="1px"&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;BorderStyle&lt;/font&gt;&lt;font color=blue&gt;="Solid"&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=red&gt;ForeColor&lt;/font&gt;&lt;font color=blue&gt;="Yellow"&lt;/font&gt;&lt;font color=black&gt; &lt;/font&gt;&lt;font color=blue&gt;/&amp;gt;&lt;br /&gt;&lt;/font&gt;&lt;font color=black&gt;&lt;/font&gt;&lt;font color=blue&gt;&amp;lt;/&lt;/font&gt;&lt;font color=maroon&gt;asp&lt;/font&gt;&lt;font color=blue&gt;:&lt;/font&gt;&lt;font color=maroon&gt;TreeView&lt;/font&gt;&lt;font color=blue&gt;&amp;gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;font color=#000000&gt;The nodes come out with a purple 1px border, green background and red text.&amp;nbsp; There is a overriding/merging of behavior between the NodeStyle and the inline styles applied through code.&amp;nbsp; The inline styles will take precedence.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font color=#000000&gt;&lt;/font&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;font color=#000000&gt;You should easily be able to create a few style properties on your custom tree nodes and data bind to them.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font color=#000000&gt;--&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font color=#000000&gt;Danny&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;/font&gt;</description></item><item><title>How to customize the styles on individual TreeNodes ?</title><link>http://forums.asp.net/thread/1152605.aspx</link><pubDate>Tue, 27 Dec 2005 16:12:51 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1152605</guid><dc:creator>srillaert</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1152605.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1152605</wfw:commentRss><description>Is there a way that we can customize the styles on individual tree nodes in the TreeView ? I ask this question because the TreeView doesn't support node templates (like the Menu control, example how to use this for node styles on the blog of &lt;a href="http://weblogs.asp.net/dannychen/archive/2005/12/02/432190.aspx"&gt;Danny Chen&lt;/a&gt;). Therefore I was looking for a solution that tries to add this to the TreeView by inheritance.&lt;br /&gt;&lt;br /&gt;Since beta 2 the TreeView has become more extensible by adding the overridable function CreateNode() which should return a TreeNode. This way one can inherit from TreeView and change its behavior so that it uses a subclass of TreeNode instead of just instantiating default TreeNode(s). &lt;br /&gt;&lt;br /&gt;However, when creating this subclass of TreeNode the only points where someone can change its appearance seems to be by overriding the RenderPreText and RenderPostText methods. This is great for adding stuff before or after the text of the tree node like checkboxes, images, etc. but it doesn't seem to help very much when one wants to change the style of the text of the tree node itself.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;&lt;span&gt;Even when one does something like (some optional technical stuff, not needed for the general question, can be skipped) :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Protected Overrides Sub RenderPreText(ByVal writer As System.Web.UI.HtmlTextWriter)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyBase.RenderPreText(writer)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "Grey")&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;This results into an attribute 'style' with value "color:Grey;" being added to the hyperlink tag surrounding the text. But in IE this css-style is overridden by the css-styles defined in the 'class' attribute on the same (hyperlink) tag (in my test case class="TreeView1_0 TreeView1_1"). The css-styles in the 'class' attribute are defined by the server styles on the TreeView itself (NodeStyle, SelectedNodeStyle, …). So it are still these TreeView styles that decide the style of the node and not the css-styles added during RenderPreText.&lt;br /&gt;---&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Any ideas about how to inherit from the TreeView and getting styles on individual nodes working ?&lt;br /&gt;&lt;br /&gt;</description></item></channel></rss>