I am working on a TreeView and have to execute the renderControl() method. When it fires, it gives an exception: InvalidOperationException: Page cannot be null. Please ensure that this operation is being performed in the context of an ASP.NET request.
I have the following code when will comment where the error is:
try{
StringWriter writer = new StringWriter();
HtmlTextWriter tOut = new HtmlTextWriter(writer);
ddFieldFilter.RenderControl(tOut); //This doesnt error.
tvFields = new RadTreeView();
tvFields.NodeExpand += new RadTreeViewEventHandler(tvFields_NodeExpand);
tvFields.NodeClick += new RadTreeViewEventHandler(tvFields_NodeClick);
startTree();
tvFields.RenderControl(tOut); //Errors here.
String context = writer.toString();
}catch(Exception e){
throw new Exception("Error Loading Page: " + e.Message);
}
Do you think it might be because there is currently content in the writer? I was thinking to clear or flush it to the string and then rebuild it. I wasnt sure it would append onto the current buffer
Let me know if you need additional Information