How to access values entered in User control in the main page.

Discussion in 'ASP .Net Web Controls' started by vineetbatta, Nov 6, 2004.

  1. vineetbatta

    vineetbatta Guest

    Hi Guys,

    i have a user control which allows the user to enter Name& Address in text
    boxes.

    I use the same user control in the main page...

    Is there a simple way of accessing the Name & address entered in the text
    boxes of the user control in the main page(Page hosting the user control
    using Resgister directive.).

    Any pointers will be helpful.

    vineet Batta
    vineetbatta, Nov 6, 2004
    #1
    1. Advertising

  2. vineetbatta wrote:
    > i have a user control which allows the user to enter Name& Address in text
    > boxes.
    >
    > I use the same user control in the main page...
    >
    > Is there a simple way of accessing the Name & address entered in the text
    > boxes of the user control in the main page(Page hosting the user control
    > using Resgister directive.).


    Create a couple of Public, read-only properties in the User Control that
    return the values of the Web controls. For example, imagine the address
    textbox in the UC has an ID of Address. You could, in your UC class, add:

    'VB.NET
    Public ReadOnly Property AddressValue as String
    Get
    Return Address.Text
    End Get
    End Property

    // C#
    public string AddressValue
    {
    get {
    return Address.Text;
    }
    }


    In your page that contains the UC you'll need to manually add a
    reference to the UC and then you can access its property just as you
    normally would.

    For more information on User Controls, check out my article:

    An Extensive Examination of User Controls
    http://tinyurl.com/6p2ju

    Happy Programming!

    --

    Scott Mitchell

    http://www.4GuysFromRolla.com

    * When you think ASP.NET, think 4GuysFromRolla.com!
    Scott Mitchell [MVP], Nov 7, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TN Bella
    Replies:
    1
    Views:
    1,476
    TN Bella
    Jul 1, 2004
  2. =?Utf-8?B?dmluZWV0YmF0dGE=?=

    How to access values entered in User control in the main page.

    =?Utf-8?B?dmluZWV0YmF0dGE=?=, Nov 6, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    526
  3. vineetbatta

    How to access values entered in User control in the main page.

    vineetbatta, Nov 6, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    132
    Scott Mitchell [MVP]
    Nov 7, 2004
  4. Arthur Dent

    Cant get user-entered values in GridView

    Arthur Dent, Mar 13, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    254
    Arthur Dent
    Mar 14, 2006
  5. Robert Oschler
    Replies:
    1
    Views:
    378
Loading...

Share This Page