473,406 Members | 2,867 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,406 software developers and data experts.

Web User Controls with multiple child elements

Hi all,

Here's a simplified example of my problem. I'm looking to have code
like this on an .aspx page:

<cc:Cameras runat="server">
<Camera Name="EOS 400D" />
<Camera Name="EOS 350D" />
</cc:Cameras>

And render HTML something like this:

<ul>
<li>EOS 400D</li>
<li>EOS 350D</li>
</ul>

I've defined a camera element CameraElement to represent each <Camera /
and a private List<CameraElementcameras so that I can store and
manipulate the list. However, I don't know how to get the
CameraElement objects into the list.

The best I have managed is this mangled property on Cameras:

public CameraElement Camera
{
set { cameras.Add(value); }
}

This seems suspect to me, and I can't find an example of how to do it
properly. How do I add the CameraElement objects to the List without
abusing a setter?

Thanks,
Douglas

Apr 8 '07 #1
4 2105
First of all, why are you not using the BulletedList control? Is there
something you plan to have your UserControl do that the BulletedList control
cannot do?
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Douglas" <ra*****@gmail.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
Hi all,

Here's a simplified example of my problem. I'm looking to have code
like this on an .aspx page:

<cc:Cameras runat="server">
<Camera Name="EOS 400D" />
<Camera Name="EOS 350D" />
</cc:Cameras>

And render HTML something like this:

<ul>
<li>EOS 400D</li>
<li>EOS 350D</li>
</ul>

I've defined a camera element CameraElement to represent each <Camera /
>and a private List<CameraElementcameras so that I can store and
manipulate the list. However, I don't know how to get the
CameraElement objects into the list.

The best I have managed is this mangled property on Cameras:

public CameraElement Camera
{
set { cameras.Add(value); }
}

This seems suspect to me, and I can't find an example of how to do it
properly. How do I add the CameraElement objects to the List without
abusing a setter?

Thanks,
Douglas

Apr 10 '07 #2
On Apr 10, 7:15 am, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
First of all, why are you not using the BulletedList control? Is there
something you plan to have your UserControl do that the BulletedList control
cannot do?
It's a simplified example, I don't plan to use bullets. The actual
page will have a series of divs with content populated using
information from the elements inside my control. I'd like to learn how
to extract information from the content supplied to my control through
the aspx page.

Is source code for the BulletedList, or something similar, available?
Then I can at least see how it does it.

Douglas

Apr 10 '07 #3
I don't know if the code for BulletedList is available, but a great book
that I know gives examples and teaches you how to do it is:

ASP.NET 2.0 Unleashed by Stephen Walther
http://www.superexpert.com/Books/Asp...d/Default.aspx
http://www.amazon.com/gp/product/0672328232

This is also a great book in general, and it is example-oriented, so you can
see complete examples of everything the author talks about. It is probably
the most helpful ASP.NET book I have ever found.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Douglas" <ra*****@gmail.comwrote in message
news:11**********************@b75g2000hsg.googlegr oups.com...
On Apr 10, 7:15 am, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
>First of all, why are you not using the BulletedList control? Is there
something you plan to have your UserControl do that the BulletedList
control
cannot do?

It's a simplified example, I don't plan to use bullets. The actual
page will have a series of divs with content populated using
information from the elements inside my control. I'd like to learn how
to extract information from the content supplied to my control through
the aspx page.

Is source code for the BulletedList, or something similar, available?
Then I can at least see how it does it.

Douglas

Apr 10 '07 #4
On Apr 10, 11:33 pm, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I don't know if the code for BulletedList is available, but a great book
that I know gives examples and teaches you how to do it is:

Cheers Nathan, will have a look for it.

Apr 13 '07 #5

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

Similar topics

3
by: Arulraja | last post by:
Hello, I have created 2 custom server controls, The parent custom control contains multiple child custom controls. The Child control has a button on it. If I Click the button control, it...
3
by: J-T | last post by:
I have a aspx page which loaded different user contols based on the users' entries.In one of my child user controls I have a property like below: public String PostID { get { return (String)...
6
by: Louise | last post by:
I use Visual Basic .NET Framework 1.1, Visual Studio. I have a Web page (aspx) referencing a control (ascx) that has a placeholder that is assigned one of 2 child controls through buttons. The...
0
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design...
8
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
9
by: abprules | last post by:
Can somehow tell me the best way for multi user development to occur in MS Access? The situation is: We are creating a new database for a small company. There are 2 of us who want to...
15
by: Ofer Zelig | last post by:
I'll describe the simplest situation of the problem. I have a simple Web User Control which only contains a: <div id="bla" runat="server" /. I dynamically add it to a page, by performing: ...
1
by: =?Utf-8?B?SmltSGVhdmV5?= | last post by:
If I create a <divand specify that I want the font-size to be 1.2em for instance, why do the <asp:controls not follow this rule if they are contained within the <divstatement? How/what do I need...
2
by: =?Utf-8?B?RGlmZmlkZW50?= | last post by:
Hello All, I have a base usercontrol which has a datagrid and a virtual method to populate the datagrid. I developed a child usercontrol which inherits the base usercontrol and also overrides...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.