Custom Control rendering in designer with object reference error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yarbrough40
    Contributor
    • Jun 2009
    • 320

    #1

    Custom Control rendering in designer with object reference error

    hey gang, I created a custom server control. The control works perfectly when added into a project. The issue I have though, is that in the designer - it shows the error --> "Error creating control - MyControl1 Object Reference not set to an instance of an object"
    The error is because I am using this code to load startup scripts
    Code:
    Dim pg As Page = HttpContext.Current.Handler
    if i comment it out then the designer does not throw the object reference error so I know this is where the problem is. So here is my question: How can I get the designer to ignore the HttpContext.Cur rent.Handler object for rendering puroposes?
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    Hey Yar,

    Did you find an answer to your question?

    CroCrew~

    Comment

    • yarbrough40
      Contributor
      • Jun 2009
      • 320

      #3
      Hey there! yes I finally did. The error went away when I added a
      Code:
      If Not HttpContext.Current Is Nothing
      Simple as that : )
      thanks for checking in

      Comment

      Working...