Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > How to access values entered in User control in the main page.

Reply
Thread Tools

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

 
 
vineetbatta
Guest
Posts: n/a
 
      11-06-2004
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
 
Reply With Quote
 
 
 
 
Scott Mitchell [MVP]
Guest
Posts: n/a
 
      11-07-2004
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.velocityreviews.com/forums/(E-Mail Removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to access values entered in User control in the main page. vineetbatta ASP .Net Building Controls 1 11-07-2004 01:28 AM
How to access values entered in User control in the main page. =?Utf-8?B?dmluZWV0YmF0dGE=?= ASP .Net 2 11-07-2004 12:18 AM
Date entered from textbox becomes null (1/1/1900) when entered into SQL table. TN Bella ASP .Net 1 07-01-2004 02:53 PM



Advertisments