Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   How to access values entered in User control in the main page. (http://www.velocityreviews.com/forums/t774711-how-to-access-values-entered-in-user-control-in-the-main-page.html)

vineetbatta 11-06-2004 11:33 PM

How to access values entered in User control in the main page.
 
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

Scott Mitchell [MVP] 11-07-2004 01:21 AM

Re: How to access values entered in User control in the main page.
 
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
mitchell@4guysfromrolla.com
http://www.4GuysFromRolla.com

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


All times are GMT. The time now is 10:08 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


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