User Control Inheritance Problem

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default User Control Inheritance Problem

    I'm trying to use several web user controls on a page that share some common
    functionality. So, I want the user controls to inherit from a base class.
    I started off making this simple base class

    Public Class BaseClass : Inherits System.Web.UI.UserControl
    Public Property TableWidth as Integer
    Get
    Return baseTable.Width
    End Get
    Set (ByVal Value As Integer)
    baseTable.Width = Value
    End Set
    End Property

    Protected WithEvents baseTable As System.Web.UI.WebControls.Table
    End Class

    I have the code behind for a child class called ChildControl that looks like
    this

    Public MustInherit Class ChildControl : Inherits BaseClass
    ' Standard wizard generated code here...
    End Class

    This code compiles and runs without any problems, but I'm unable to open my
    user control in the form designer anymore. I get the following error:

    "The file failed to load in the Web Form Designer. Please correct the
    following error, then load it again: Property accessor TableWidth on object
    ChildControl threw the following exception: 'Object reference not set to an
    instance of an object.'"

    Is this a known bug with the form designer? Is there any work around so I
    can have my control inherit from a base class AND be able to edit it in the
    form designer?

    Tom
    tjmii@rocketmail.com Guest

  2. Similar Questions and Discussions

    1. user control problem access value from user control to a page
      Thanks a lot for paying attention to my problem , i tell u the problem i have a main form in which i gave a login label that points to a...
    2. Problem of User Control
      Hello, I am newbie of ASP.NET. I tried to develop a simple user control and add it to a web page for testing. However, when I start debug, the web...
    3. PROBLEM WITH USER CONTROL
      Dear all i'm facing a problem in creating a user control that allows me to set inside this user control an instance of a dataset and to set an...
    4. Problem with web user control
      Hi! I have a user control WebUserControl1.ascx with a textbox.I want to change the text of the textbox from another page but i get the error...
    5. User control problem
      Hi all, I have a usercontrol which contains others. How do I get the info from these embedded usercontrols from my parent usercontrol? Regards...
  3. #2

    Default Re: User Control Inheritance Problem

    I did a search on google before posting, but did not find anything that was
    useful. I found one post about making the base class abstract, but that did
    not make any difference. Could you provide a link, or let me know what
    needs to be done to resolve this problem? Thanks.

    Tom
    tjmii@rocketmail.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139