User control newbie question - pls help

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

  1. #1

    Default User control newbie question - pls help

    I have a user control with a label and a method. The webform should call
    the method on the user control and populate the label. I am getting
    object not set errors as soon as I try to access the label on the user
    control.

    A small sample of code would be greatly appreciated.


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Paul Barnett Guest

  2. Similar Questions and Discussions

    1. Web User Control question
      I have a web user control that I wrote. I'm new to doing this. Doesn't seem like a big deal though. One thing I wonder about, and although maybe...
    2. User Control Populate Form after Log On - newbie question
      Hi, I have a user control that contains a login element, textboxes for username and password, and a button to submit, which appears in the header...
    3. Page_Load called more than once for user control - newbie question
      Hi, I have a page with a user control as header, which in turn has a user control drop down list. When I run the page in debug with a break on...
    4. Newbie Question: User selected query
      I have a datagrid that is populated by a SQL query that is create by the user. Their is a DropDOwnList and a textbox. This gives them the WHERE...
    5. Newbie Web Service Question regarding User Controls
      Can I return a user control from a Web Service? I have a Web Page that has a Placeholder on it and I wish to populate this placeholder with a...
  3. #2

    Default Re: User control newbie question - pls help

    Nice little "secret" solution to this I believe.

    You need to explicitly declare the object variable for your user control,
    unlike when you add a normal control and VS does it for you:

    Protected WithEvents Control ID As UsercontrolType (where Control ID is the
    id of the control after you dragged it onto your web form, and
    usercontroltype is the class name)

    Hope this helps. Not sure if the WithEvents is required or recommend, might
    depend on your implementation

    "Paul Barnett" <paul@barnett23.eclipse.co.uk> wrote in message
    news:%23v%23WvLGiDHA.1508@TK2MSFTNGP10.phx.gbl...
    > I have a user control with a label and a method. The webform should call
    > the method on the user control and populate the label. I am getting
    > object not set errors as soon as I try to access the label on the user
    > control.
    >
    > A small sample of code would be greatly appreciated.
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Travis Bolton Guest

  4. #3

    Default Re: User control newbie question - pls help

    Small note: keep in mind that for the parser to do its magic, you need to
    name your member variable *exactly* after the value of the ID attribute
    given in your usercontrol tag.

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    [url]http://obies.com/vga/blog.aspx[/url]
    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    and not by private mail.

    "Travis Bolton" <travis.bolton@sbcglobal.net> wrote in message
    news:OK71g7XmDHA.2364@TK2MSFTNGP11.phx.gbl...
    > Nice little "secret" solution to this I believe.
    >
    > You need to explicitly declare the object variable for your user control,
    > unlike when you add a normal control and VS does it for you:
    >
    > Protected WithEvents Control ID As UsercontrolType (where Control ID is
    the
    > id of the control after you dragged it onto your web form, and
    > usercontroltype is the class name)
    >
    > Hope this helps. Not sure if the WithEvents is required or recommend,
    might
    > depend on your implementation
    >
    > "Paul Barnett" <paul@barnett23.eclipse.co.uk> wrote in message
    > news:%23v%23WvLGiDHA.1508@TK2MSFTNGP10.phx.gbl...
    > > I have a user control with a label and a method. The webform should call
    > > the method on the user control and populate the label. I am getting
    > > object not set errors as soon as I try to access the label on the user
    > > control.
    > >
    > > A small sample of code would be greatly appreciated.
    > >
    > >
    > > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > > Don't just participate in USENET...get rewarded for it!
    >
    >

    Victor Garcia Aprea [MVP] 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