Click here to Skip to main content
12,349,766 members (26,649 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#2.0 C# 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 4-Feb-10 23:33pm
Edited 5-Feb-10 0:24am
Rate this: bad
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; }
Then you can set TextBoxText in your aspx, or you can access the properties in your code behind.
Rate this: bad
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".

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

Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 6 Feb 2010
Copyright © CodeProject, 1999-2016
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