473,388 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

C# Web User Control help

hey all,
I have web user control (c# code-behind) and i'm trying to create a property
that will provide the user with a drop down list of values inside the
property box for that web user control instance and I'm having trouble with
the syntax, can someone please help me?

thanks,
rodchar
Apr 9 '07 #1
3 2012
On Apr 9, 11:18 am, rodchar <rodc...@discussions.microsoft.comwrote:
hey all,
I have web user control (c# code-behind) and i'm trying to create a property
that will provide the user with a drop down list of values inside the
property box for that web user control instance and I'm having trouble with
the syntax, can someone please help me?

thanks,
rodchar
Lets say the user control contains a ListBox or a DropDownList. Lets
also assume it's named lstValues. You can make this list available to
the form using the user control by providing a public property of the
lstValues Items property.

public ListitemsCollection Items
{
get { return lstValues.Items; }
}

This will expose the Items property to the form containing the user
control. You can now use the add method of this property to add items
to this list of items.

uc1.Items.add(mylistitem);

You can also iterate through it ...

foreach(ListItem li in ux1.Items)

Apr 9 '07 #2
is this possible with an enum list?

"wmain" wrote:
On Apr 9, 11:18 am, rodchar <rodc...@discussions.microsoft.comwrote:
hey all,
I have web user control (c# code-behind) and i'm trying to create a property
that will provide the user with a drop down list of values inside the
property box for that web user control instance and I'm having trouble with
the syntax, can someone please help me?

thanks,
rodchar

Lets say the user control contains a ListBox or a DropDownList. Lets
also assume it's named lstValues. You can make this list available to
the form using the user control by providing a public property of the
lstValues Items property.

public ListitemsCollection Items
{
get { return lstValues.Items; }
}

This will expose the Items property to the form containing the user
control. You can now use the add method of this property to add items
to this list of items.

uc1.Items.add(mylistitem);

You can also iterate through it ...

foreach(ListItem li in ux1.Items)

Apr 9 '07 #3
No problem.
Here's some sample code that should do the trick:

public enum AppType: int
{
HTML,
Word,
Excel,
PowerPoint,
WordPerfect
}

//Manage the requested export type
private AppType m_AppType;
[Bindable(true), Category("Behavior")]
public AppType ExportType
{
get
{
return m_AppType;
}

set
{
m_AppType= value;
}
}

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:6B**********************************@microsof t.com...
hey all,
I have web user control (c# code-behind) and i'm trying to create a
property
that will provide the user with a drop down list of values inside the
property box for that web user control instance and I'm having trouble
with
the syntax, can someone please help me?

thanks,
rodchar
Apr 11 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tim Thomas | last post by:
Hi, I am very new to .NET and am in the process of building my first web application. I will briefly describe what i am trying to achieve: I have a system where suppliers register their...
13
by: Lloyd Sheen | last post by:
I have now spent 5 hours on google/msdn looking for something useful in the creation of user controls for asp.net. The VS 2003 has very limited support for things such as absolute positioning of...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
6
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
5
by: Dave | last post by:
(Second Try) Greetings, I have an asp.net web application that utilizes a User Control at the top of the page. My User Control contains a Server Control menu which will require postbacks. ...
7
by: Smithers | last post by:
I have a non trivial ASP.NET Web application that implements its navigation system via a user control (menu.ascx) placed on every page. It is important to note that the user control that hosts...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
4
by: thomson | last post by:
Hi all, i do have a user control with 4 buttons, and all the events are firing properly, My problem is that i need to right an event handler in the user control, which gets fired after a...
8
by: Paul Bromley | last post by:
I am trying to get somewhere with user controls and have come up against an obstacle with using relative paths. I have a dataset in my user control, and have tried to enter the path with the...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.