D
David Wiart
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)
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)