User control question

  • Thread starter Thread starter Stan Sainte-Rose
  • Start date Start date
S

Stan Sainte-Rose

Hi guys,
I have a page with several textboxes..
In the same page, I set a user control with a button.
I would like to know how to catch the different values from the textboxes
when I click on the button.

Stan
 
Stan said:
I have a page with several textboxes..
In the same page, I set a user control with a button.
I would like to know how to catch the different values from the textboxes
when I click on the button.

Are you wanting to read the TextBox values from the User Control? This
you shouldn't do, as the user control should be ignorant about the page
that contains it.

If you want the ASP.NET Web page to do some processing when the User
Control's button is clicked, the best way, IMO, is to have the user
control raise an event when its button is clicked. The page, then, can
have an event handler for this event.

I discuss this approach and provide a C# code example in the article:

An Extensive Examination of User Controls
http://msdn.microsoft.com/asp.net/u...l=/library/en-us/dnaspp/html/usercontrols.asp

Happy Programming!

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
Hi Scott

I agree with you I didn't have a good approach..
but I found a way using this following syntax
Me.Parent.FindControl("MyControl")
It seems to work fine..
But I will read your article and see how I can change my user control.

Thanks for your post.

Stan
 
Back
Top