User control question

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
 
S

Scott Mitchell [MVP]

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!
 
S

Stan Sainte-Rose

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top