Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Treeview and rendercontrol

Reply
Thread Tools

Treeview and rendercontrol

 
 
David Wiart
Guest
Posts: n/a
 
      09-20-2006
Hi,

I try to get the html code of the treeview by doing this :

TreeView Tview = new TreeView();
TreeNode tnode = new TreeNode("Node1", "1");
Tview.Nodes.Add(tnode);
Tview.ID = "Tree1";
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
Tview.RenderControl(hw);

But I get the following exception and I found no solution for the
moment, please help !!

-----------------------------------------------------------------------------------------------------------------------------------
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="System.Web"
StackTrace:
at System.Web.UI.Control.get_SpacerImageUrl()
at
System.Web.UI.WebControls.TreeView.RenderBeginTag( HtmlTextWriter
writer)
at System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter
writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter
writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at WebControlLibrary1.MyControl.RenderContents(HtmlTe xtWriter
output) in C:\Work\WebSite1\WebControlLibrary1\MyControl.cs:l ine 27
at System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter
writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter
writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlT extWriter
writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
at
System.Web.UI.HtmlControls.HtmlForm.RenderChildren (HtmlTextWriter
writer)
at
System.Web.UI.HtmlControls.HtmlContainerControl.Re nder(HtmlTextWriter
writer)
at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTex tWriter
output)
at System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter
writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at
System.Web.UI.HtmlControls.HtmlForm.RenderControl( HtmlTextWriter
writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlT extWriter
writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
at System.Web.UI.Control.Render(HtmlTextWriter writer)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter
writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TreeView control postback on click of plus sign when rendered using RenderControl vikasparihar Software 1 07-09-2010 07:48 PM
RenderControl and asp:TreeView GroupReader ASP .Net 1 03-29-2007 10:42 PM
RenderControl and TreeView GroupReader ASP .Net Web Controls 0 03-28-2007 11:08 PM
TreeView in Custom User Control RenderControl error apenly@gmail.com ASP .Net 0 11-07-2006 06:37 PM
TreeView in 2.0 and RenderControl zoneboy@gmail.com ASP .Net 0 08-25-2005 12:31 PM



Advertisments