Click here to Skip to main content
15,886,071 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to create a user control in C# .Net Web Application with 2 drop downs & 1 Text Box.I want to access that control on my .CS Page.How to assign propeties to a control?
Posted
Updated 5-Feb-10 0:24am
v2

I assume you meant to say this is ASP.NET ?

You just put the controls inside your user control. Then you create properties inside the user control class, which map to the properties of the controls, such as

<pre>public string TextBoxText
{
get { return TextBox1.Text; }
set { TextBox1.Text = value; }
}</pre>
Then you can set TextBoxText in your aspx, or you can access the properties in your code behind.
 
Share this answer
 
v3
The answer given above is right, but you will be confronted other question, you cannot send events from UserControls to the webpages where your usercontrols are being using.

Just Checkout "Delegate".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900