Click here to Skip to main content
12,953,937 members (42,927 online)
Rate this:
 
Please Sign up or sign in to 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 4-Feb-10 23:33pm
Updated 5-Feb-10 0:24am
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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".
  Permalink  

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,464
CHill60 3,490
Maciej Los 3,123
ppolymorphe 2,020
Jochen Arndt 1,975


Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 6 Feb 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100