Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Spacer Image URL error

Spacer Image URL error

Scheduled Pinned Locked Moved ASP.NET
csharphtmlasp-netdesignsysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bigmacrox
    wrote on last edited by
    #1

    Hi, I tried to initialize a new TreeView control in ASP.NET 2.0, so I could display its HTML output through the RenderControl method. But when I run the website I get the following error: [NullReferenceException: Object reference not set to an instance of an object.] System.Web.UI.Control.get_SpacerImageUrl() +59 System.Web.UI.WebControls.TreeView.RenderBeginTag(HtmlTextWriter writer) +147 System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +17 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +53 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +280 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24 Test.button1_Click(Object sender, EventArgs e) in c:\... System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +97 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4919 Since the stack trace terminates at the method get_SpacerImageUrl(), I assume that I didn't set some property of the TreeView control when I was intializing it. Anybody know which property I have to set to avoid this error? Or am I completely off the mark? I initialized the TreeView control as follows: TreeView tv = new TreeView(); tv.ImageSet = TreeViewImageSet.Inbox; tv.ShowLines = true; tv.ID = "treeViewTest"; tv.Nodes.Add(new TreeNode("test")); StringBuilder sw = new StringBuilder(); //stores the HTML of the TreeView Control StringWriter st = new StringWriter(sw); HtmlTextWriter writer = new HtmlTextWriter(st); tv.RenderControl(writer);//outputs the html of the treeview control to writer labelContent.Text = Server.HtmlEncode(sw.ToString()); Thanks.

    M 1 Reply Last reply
    0
    • B bigmacrox

      Hi, I tried to initialize a new TreeView control in ASP.NET 2.0, so I could display its HTML output through the RenderControl method. But when I run the website I get the following error: [NullReferenceException: Object reference not set to an instance of an object.] System.Web.UI.Control.get_SpacerImageUrl() +59 System.Web.UI.WebControls.TreeView.RenderBeginTag(HtmlTextWriter writer) +147 System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +17 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +53 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +280 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24 Test.button1_Click(Object sender, EventArgs e) in c:\... System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +97 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4919 Since the stack trace terminates at the method get_SpacerImageUrl(), I assume that I didn't set some property of the TreeView control when I was intializing it. Anybody know which property I have to set to avoid this error? Or am I completely off the mark? I initialized the TreeView control as follows: TreeView tv = new TreeView(); tv.ImageSet = TreeViewImageSet.Inbox; tv.ShowLines = true; tv.ID = "treeViewTest"; tv.Nodes.Add(new TreeNode("test")); StringBuilder sw = new StringBuilder(); //stores the HTML of the TreeView Control StringWriter st = new StringWriter(sw); HtmlTextWriter writer = new HtmlTextWriter(st); tv.RenderControl(writer);//outputs the html of the treeview control to writer labelContent.Text = Server.HtmlEncode(sw.ToString()); Thanks.

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      You need to add the TreeView control to the control hierarchy of the current Page, also the rendering will cause the error if the form does not get rendered or the Page is not in the callback. I'm curious that why you don't just add the TreeView control to the Page and leave it render normally.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups