Dynamically Add User Control

T

Terry Holland

Ive started a new thread as original seems to have dried up. I was replying
to Steven Cheng.

Steven

Im getting in a bit of a mess with this. What I want to end up with is a
set of controls for editing / displaying fields on a webform. I would like
to be able to dynamically add these controls to webforms as and when I need
them.

Initially I need three types of fields

ctlFieldReadOnly
ctlFieldEditable
ctlFieldEditableRequired

Each of these controls will consist of the following controls:

ctlFieldReadOnly: Label (lblLabel) and a label (lblValue) to display the
data
ctlFieldEditable: Label (lblLabel) and a textbox (txtValue - background
colour blue) to the display the data
ctlFieldEditableRequired: Label (lblLabel) and a textbox (txtValue -
background colour yellow) to the display the data.

Each of these controls needs to expose a Label property and a Value
property.
Each control should be able to be configured so the either, the Label
control is above the Value control, or the Label control appears to the Left
of the Value control.

Each form may contain any number of each type of control.

Ive been trying to develop along the following lines:
Create a Base control such as ctlField that must be inherited. This control
will contain the properties Label, Value, Width and HorizontalAlignment.
Im then trying to derive the required controls from this control. My derived
controls should add the relevant webcontrols ie Label to display the Value
for a ctlReadOnly control, a Textbox to display the Value for
ctlFieldEditable & ctlFieldEditableRequired controls.
Im getting various results ranging from no controls being displayed, not
being able to refer to controls in order to read/write values.

It would be very helpful if you could provide a small sample of how I might
get this sort of scenario to work (VB if possible - I know you prefer C#)


Terry
 
D

Duane Hookom

This has nothing to do with Microsoft Access. I suggest you find a more
appropriate news group.
 
M

Michael Cheng [MSFT]

Hi Terry,

Steven has replied this thread in
microsoft.public.dotnet.framework.aspnet.buildingcontrols. Pleaes reply his
post in that thread. If you have any questions or concerns, please feel
free to let me know.

Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!


Sincerely yours,

Michael Cheng
Microsoft Online Partner Support

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top