Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 ASP.NET
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 5-Feb-10 0:33am
Edited 5-Feb-10 1: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
0 OriginalGriff 277
1 Maciej Los 220
2 DamithSL 190
3 Raul Iloc 185
4 Richard MacCutchan 175
0 OriginalGriff 5,130
1 DamithSL 4,197
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 6 Feb 2010
Copyright © CodeProject, 1999-2014
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