Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

setting properties on child controls of Custom web user controls

1 view
Skip to first unread message

Andy B

unread,
Apr 24, 2008, 4:38:59 PM4/24/08
to
I am creating a custom web user control that is a complex page view. I want
to use it as the confirm step of a wizard control. Inside the custom user
control, there will be different label controls that will display the text
of different things. What do I need to do in order to access the text
property of these labels? Do I need to make public accessers/properties that
access the label.text property? or do I just access the
usercontrol.Label.text property?

Milosz Skalecki [MCAD]

unread,
Apr 24, 2008, 7:38:00 PM4/24/08
to
Hi Andy,

I would go for exposing text property of the child controls(labels):

public string HeaderText
{
get
{
return lblHeader.Text;
}
set
{
lblHeader.Text = value
}
}

simply because only "text" on the label is being changed. If you had to set
many properties of the same label (i.e. Text, Font, BackgroundColor) it would
be easier and quicker to expose Label as property (please note it does not
require setter because you want to allow control consumers to change label's
properties, not the actual reference):

public Label HeaderLabel
{
get
{
return lblHeader;
}
}

As you can see it depends on the purpose.

Hope it helps
--
Milosz

Andy B

unread,
Apr 24, 2008, 9:17:57 PM4/24/08
to
I will probably go for the exposing the Text property of the labels as
control properties. This "ConfirmContractView" control does nothing at all
except show the page view the way it is supposed to be seen in the
production service. That way when a new contract is created or changed it is
shown to the admin so they know if the editing or creation was done right.
It is fed all of its values through the controls in a wizard control. So, I
think we got this part covered.

On the same note of exposing control properties, Here is a more complex
question that might require a little bit of coding on my part. I need to
have a web user control (just like the one above), except that it is fed its
values through a live website environment. In other words, it will be fed
its values through user input, objects and a few different dataSources. Do
you think I should make a different control for this part of the
application? or is it possible to extend the one above to include getting
its sources through other means besides the text property of a label
control. If it is possible to extend the control above so it doesn't have to
be rewritten, how would you hide the labels text properties and expose the
ones needed? I was thinking of a property of some kind, maybe like a
Control.Mode property that would determine if the control was in ConfirmView
or UserView. If it is in ConfirmView the label.text properties are exposed
and the other "live" dataSources are hidden. If it is in UserView, then the
label.text properties are hidden and the other datasource properties are
exposed. How hard would it be to do something like this? and how would you
do it? is there an article somewhere if it is complicated to do?


"Milosz Skalecki [MCAD]" <mil...@DONTLIKESPAMwp.pl> wrote in message
news:EE1D2391-FBBF-4434...@microsoft.com...

0 new messages