Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Alphonse Giambrone #1
Composite Control Property Setting Problem
I have built a simple composite control that consists of a textbox,
requiredfieldvalidator and rangevalidator.
For properties that are unique to the individual control, I set/get them
directly from the control as follows:
[Description("The text value"),
Bindable(true),
Browsable(true),
Category("TextBox"),
DefaultValue("")]
public string Text
{
get
{
EnsureChildControls();
return txt1.Text;
}
set
{
EnsureChildControls();
txt1.Text = value;
}
}
For properties that are common to more than one control or that I want to
additionally manipulate within the composite, I use private static variables
and then assign each control the variable's value before adding it to the
controls collection:
private static string _mstrValCssClass="";
[Description("CssClass to apply to validator portion of control"),
Browsable(true),
Category("Validators")]
public string ValCssClass
{
get
{
return _mstrValCssClass;
}
set
{
_mstrValCssClass = value;
}
}
This all seemed to work well when adding the composite dynamically or using
only one on a user control. My problem when I add two of the composites to a
user control in the designer. Using the above property as an example, if I
set the ValCssClass of mycomposite1 to myclass1 and set the ValCssClass of
mycomposite2 to myclass2, then the property also changes for mycomposite1
and viceversa. This only happens with the properties that utilize a static
variable, not the ones that are set per the first property example.
Can anyone explain this and possibly provide a solution?
TIA
--
Alphonse Giambrone
Email: a-giam at customdatasolutions dot us
Alphonse Giambrone Guest
-
Composite Control with FormView property tag prefix attribute?
Hi, I've developed a Composite control designed to take one FormView and one SqlDataSource as properties. I can add my composite control to the... -
Losing Composite Control property that another Composite Control ...
Hi, I'm creating 2 composite controls in ASP.net. Control 1 is a Search control and control 2 is a Map control. I have added a property... -
Property Not saved in Composite Control... Help & Pointers required.
I have created a coposite control, consisting of text, labels , radiobuttons and checkboxes the purpose is to create a generic control to manage... -
Composite control with dynamic controls depending on a property value
Hi, all. I am really stuck here. I've written a few composite controls before and fully understand the "typical" scenarios. However, this one is... -
Composite WebControl -- Child Control Property Persistance at Design-time
Hi, I seen, this asked a number of times at this group but still have not seen any complete/rectified/fixed code. I have created a Composite... -
John Saunders #2
Re: Composite Control Property Setting Problem
"Alphonse Giambrone" <NOSPAMa-giam@example.invalid> wrote in message
news:ece3H%23TYEHA.2672@tk2msftngp13.phx.gbl...variables> I have built a simple composite control that consists of a textbox,
> requiredfieldvalidator and rangevalidator.
>
> For properties that are unique to the individual control, I set/get them
> directly from the control as follows:
> [Description("The text value"),
> Bindable(true),
> Browsable(true),
> Category("TextBox"),
> DefaultValue("")]
> public string Text
> {
> get
> {
> EnsureChildControls();
> return txt1.Text;
> }
>
> set
> {
> EnsureChildControls();
> txt1.Text = value;
> }
> }
>
> For properties that are common to more than one control or that I want to
> additionally manipulate within the composite, I use private staticusing> and then assign each control the variable's value before adding it to the
> controls collection:
>
> private static string _mstrValCssClass="";
>
> [Description("CssClass to apply to validator portion of control"),
> Browsable(true),
> Category("Validators")]
> public string ValCssClass
> {
> get
> {
> return _mstrValCssClass;
> }
> set
> {
> _mstrValCssClass = value;
> }
> }
>
> This all seemed to work well when adding the composite dynamically ora> only one on a user control. My problem when I add two of the composites toYes. Don't use statics. "static" means it's a member of the class, not a> user control in the designer. Using the above property as an example, if I
> set the ValCssClass of mycomposite1 to myclass1 and set the ValCssClass of
> mycomposite2 to myclass2, then the property also changes for mycomposite1
> and viceversa. This only happens with the properties that utilize a static
> variable, not the ones that are set per the first property example.
>
> Can anyone explain this and possibly provide a solution?
member of a class instance. Each time you drop your control on a page, you
get a new instance of the control, but all instances will share the same
static members.
So, "don't do that"!
--
John Saunders
johnwsaundersiii at hotmail
John Saunders Guest
-
Alphonse Giambrone #3
Re: Composite Control Property Setting Problem
Thanks for the speedy reply and info John.
I don't recall just why I made the variables static, but removing the static
does solve the problem.
--
Alphonse Giambrone
Email: a-giam at customdatasolutions dot us
"John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
news:OfwOrjVYEHA.3988@tk2msftngp13.phx.gbl...to> "Alphonse Giambrone" <NOSPAMa-giam@example.invalid> wrote in message
> news:ece3H%23TYEHA.2672@tk2msftngp13.phx.gbl...> > I have built a simple composite control that consists of a textbox,
> > requiredfieldvalidator and rangevalidator.
> >
> > For properties that are unique to the individual control, I set/get them
> > directly from the control as follows:
> > [Description("The text value"),
> > Bindable(true),
> > Browsable(true),
> > Category("TextBox"),
> > DefaultValue("")]
> > public string Text
> > {
> > get
> > {
> > EnsureChildControls();
> > return txt1.Text;
> > }
> >
> > set
> > {
> > EnsureChildControls();
> > txt1.Text = value;
> > }
> > }
> >
> > For properties that are common to more than one control or that I wantthe> variables> > additionally manipulate within the composite, I use private static> > and then assign each control the variable's value before adding it toto> using> > controls collection:
> >
> > private static string _mstrValCssClass="";
> >
> > [Description("CssClass to apply to validator portion of control"),
> > Browsable(true),
> > Category("Validators")]
> > public string ValCssClass
> > {
> > get
> > {
> > return _mstrValCssClass;
> > }
> > set
> > {
> > _mstrValCssClass = value;
> > }
> > }
> >
> > This all seemed to work well when adding the composite dynamically or> > only one on a user control. My problem when I add two of the compositesI> a> > user control in the designer. Using the above property as an example, ifof> > set the ValCssClass of mycomposite1 to myclass1 and set the ValCssClassmycomposite1> > mycomposite2 to myclass2, then the property also changes forstatic> > and viceversa. This only happens with the properties that utilize a>> > variable, not the ones that are set per the first property example.
> >
> > Can anyone explain this and possibly provide a solution?
> Yes. Don't use statics. "static" means it's a member of the class, not a
> member of a class instance. Each time you drop your control on a page, you
> get a new instance of the control, but all instances will share the same
> static members.
>
> So, "don't do that"!
> --
> John Saunders
> johnwsaundersiii at hotmail
>
>
Alphonse Giambrone Guest
-
MS News \(MS ILM\) #4
Re: Composite Control Property Setting Problem
can I use the same attributes [Description("The text value"),
etc... in VB.NET
SA
"John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
news:OfwOrjVYEHA.3988@tk2msftngp13.phx.gbl...to> "Alphonse Giambrone" <NOSPAMa-giam@example.invalid> wrote in message
> news:ece3H%23TYEHA.2672@tk2msftngp13.phx.gbl...> > I have built a simple composite control that consists of a textbox,
> > requiredfieldvalidator and rangevalidator.
> >
> > For properties that are unique to the individual control, I set/get them
> > directly from the control as follows:
> > [Description("The text value"),
> > Bindable(true),
> > Browsable(true),
> > Category("TextBox"),
> > DefaultValue("")]
> > public string Text
> > {
> > get
> > {
> > EnsureChildControls();
> > return txt1.Text;
> > }
> >
> > set
> > {
> > EnsureChildControls();
> > txt1.Text = value;
> > }
> > }
> >
> > For properties that are common to more than one control or that I wantthe> variables> > additionally manipulate within the composite, I use private static> > and then assign each control the variable's value before adding it toto> using> > controls collection:
> >
> > private static string _mstrValCssClass="";
> >
> > [Description("CssClass to apply to validator portion of control"),
> > Browsable(true),
> > Category("Validators")]
> > public string ValCssClass
> > {
> > get
> > {
> > return _mstrValCssClass;
> > }
> > set
> > {
> > _mstrValCssClass = value;
> > }
> > }
> >
> > This all seemed to work well when adding the composite dynamically or> > only one on a user control. My problem when I add two of the compositesI> a> > user control in the designer. Using the above property as an example, ifof> > set the ValCssClass of mycomposite1 to myclass1 and set the ValCssClassmycomposite1> > mycomposite2 to myclass2, then the property also changes forstatic> > and viceversa. This only happens with the properties that utilize a>> > variable, not the ones that are set per the first property example.
> >
> > Can anyone explain this and possibly provide a solution?
> Yes. Don't use statics. "static" means it's a member of the class, not a
> member of a class instance. Each time you drop your control on a page, you
> get a new instance of the control, but all instances will share the same
> static members.
>
> So, "don't do that"!
> --
> John Saunders
> johnwsaundersiii at hotmail
>
>
MS News \(MS ILM\) Guest
-
John Saunders #5
Re: Composite Control Property Setting Problem
Yes, you can, but the syntax is different. You need angle brackets instead
of square brackets:
<[Description("The text value")>
--
John Saunders
johnwsaundersiii at hotmail
"MS News (MS ILM)" <sql_agentmans@hotmail.com> wrote in message
news:O$ZqAmZYEHA.808@tk2msftngp13.phx.gbl...them> can I use the same attributes [Description("The text value"),
> etc... in VB.NET
>
> SA
>
> "John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
> news:OfwOrjVYEHA.3988@tk2msftngp13.phx.gbl...> > "Alphonse Giambrone" <NOSPAMa-giam@example.invalid> wrote in message
> > news:ece3H%23TYEHA.2672@tk2msftngp13.phx.gbl...> > > I have built a simple composite control that consists of a textbox,
> > > requiredfieldvalidator and rangevalidator.
> > >
> > > For properties that are unique to the individual control, I set/getcomposites> to> > > directly from the control as follows:
> > > [Description("The text value"),
> > > Bindable(true),
> > > Browsable(true),
> > > Category("TextBox"),
> > > DefaultValue("")]
> > > public string Text
> > > {
> > > get
> > > {
> > > EnsureChildControls();
> > > return txt1.Text;
> > > }
> > >
> > > set
> > > {
> > > EnsureChildControls();
> > > txt1.Text = value;
> > > }
> > > }
> > >
> > > For properties that are common to more than one control or that I want> the> > variables> > > additionally manipulate within the composite, I use private static> > > and then assign each control the variable's value before adding it to> > using> > > controls collection:
> > >
> > > private static string _mstrValCssClass="";
> > >
> > > [Description("CssClass to apply to validator portion of control"),
> > > Browsable(true),
> > > Category("Validators")]
> > > public string ValCssClass
> > > {
> > > get
> > > {
> > > return _mstrValCssClass;
> > > }
> > > set
> > > {
> > > _mstrValCssClass = value;
> > > }
> > > }
> > >
> > > This all seemed to work well when adding the composite dynamically or> > > only one on a user control. My problem when I add two of theif> to> > a> > > user control in the designer. Using the above property as an example,ValCssClass> I> > > set the ValCssClass of mycomposite1 to myclass1 and set theyou> of> mycomposite1> > > mycomposite2 to myclass2, then the property also changes for> static> > > and viceversa. This only happens with the properties that utilize a> >> > > variable, not the ones that are set per the first property example.
> > >
> > > Can anyone explain this and possibly provide a solution?
> > Yes. Don't use statics. "static" means it's a member of the class, not a
> > member of a class instance. Each time you drop your control on a page,>> > get a new instance of the control, but all instances will share the same
> > static members.
> >
> > So, "don't do that"!
> > --
> > John Saunders
> > johnwsaundersiii at hotmail
> >
> >
>
John Saunders Guest
-
John Saunders #6
Re: Composite Control Property Setting Problem
Sorry, I meant:
<Description("The text value")>
--
John Saunders
johnwsaundersiii at hotmail
"MS News (MS ILM)" <sql_agentmans@hotmail.com> wrote in message
news:O$ZqAmZYEHA.808@tk2msftngp13.phx.gbl...them> can I use the same attributes [Description("The text value"),
> etc... in VB.NET
>
> SA
>
> "John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
> news:OfwOrjVYEHA.3988@tk2msftngp13.phx.gbl...> > "Alphonse Giambrone" <NOSPAMa-giam@example.invalid> wrote in message
> > news:ece3H%23TYEHA.2672@tk2msftngp13.phx.gbl...> > > I have built a simple composite control that consists of a textbox,
> > > requiredfieldvalidator and rangevalidator.
> > >
> > > For properties that are unique to the individual control, I set/getcomposites> to> > > directly from the control as follows:
> > > [Description("The text value"),
> > > Bindable(true),
> > > Browsable(true),
> > > Category("TextBox"),
> > > DefaultValue("")]
> > > public string Text
> > > {
> > > get
> > > {
> > > EnsureChildControls();
> > > return txt1.Text;
> > > }
> > >
> > > set
> > > {
> > > EnsureChildControls();
> > > txt1.Text = value;
> > > }
> > > }
> > >
> > > For properties that are common to more than one control or that I want> the> > variables> > > additionally manipulate within the composite, I use private static> > > and then assign each control the variable's value before adding it to> > using> > > controls collection:
> > >
> > > private static string _mstrValCssClass="";
> > >
> > > [Description("CssClass to apply to validator portion of control"),
> > > Browsable(true),
> > > Category("Validators")]
> > > public string ValCssClass
> > > {
> > > get
> > > {
> > > return _mstrValCssClass;
> > > }
> > > set
> > > {
> > > _mstrValCssClass = value;
> > > }
> > > }
> > >
> > > This all seemed to work well when adding the composite dynamically or> > > only one on a user control. My problem when I add two of theif> to> > a> > > user control in the designer. Using the above property as an example,ValCssClass> I> > > set the ValCssClass of mycomposite1 to myclass1 and set theyou> of> mycomposite1> > > mycomposite2 to myclass2, then the property also changes for> static> > > and viceversa. This only happens with the properties that utilize a> >> > > variable, not the ones that are set per the first property example.
> > >
> > > Can anyone explain this and possibly provide a solution?
> > Yes. Don't use statics. "static" means it's a member of the class, not a
> > member of a class instance. Each time you drop your control on a page,>> > get a new instance of the control, but all instances will share the same
> > static members.
> >
> > So, "don't do that"!
> > --
> > John Saunders
> > johnwsaundersiii at hotmail
> >
> >
>
John Saunders Guest
-
MS News \(MS ILM\) #7
Re: Composite Control Property Setting Problem
John,
I tried that but its telling me that Description is not defined ???
Am I missing an Import??
I checked and can not figure it out.
Thanks
"John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
news:%23y4zkjcYEHA.1048@tk2msftngp13.phx.gbl...want> Sorry, I meant:
>
> <Description("The text value")>
>
> --
> John Saunders
> johnwsaundersiii at hotmail
>
>
> "MS News (MS ILM)" <sql_agentmans@hotmail.com> wrote in message
> news:O$ZqAmZYEHA.808@tk2msftngp13.phx.gbl...> them> > can I use the same attributes [Description("The text value"),
> > etc... in VB.NET
> >
> > SA
> >
> > "John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
> > news:OfwOrjVYEHA.3988@tk2msftngp13.phx.gbl...> > > "Alphonse Giambrone" <NOSPAMa-giam@example.invalid> wrote in message
> > > news:ece3H%23TYEHA.2672@tk2msftngp13.phx.gbl...
> > > > I have built a simple composite control that consists of a textbox,
> > > > requiredfieldvalidator and rangevalidator.
> > > >
> > > > For properties that are unique to the individual control, I set/get> > > > directly from the control as follows:
> > > > [Description("The text value"),
> > > > Bindable(true),
> > > > Browsable(true),
> > > > Category("TextBox"),
> > > > DefaultValue("")]
> > > > public string Text
> > > > {
> > > > get
> > > > {
> > > > EnsureChildControls();
> > > > return txt1.Text;
> > > > }
> > > >
> > > > set
> > > > {
> > > > EnsureChildControls();
> > > > txt1.Text = value;
> > > > }
> > > > }
> > > >
> > > > For properties that are common to more than one control or that Ito> > to> > > > additionally manipulate within the composite, I use private static
> > > variables
> > > > and then assign each control the variable's value before adding it> > the> > > > controls collection:
> > > >
> > > > private static string _mstrValCssClass="";
> > > >
> > > > [Description("CssClass to apply to validator portion of control"),or> > > > Browsable(true),
> > > > Category("Validators")]
> > > > public string ValCssClass
> > > > {
> > > > get
> > > > {
> > > > return _mstrValCssClass;
> > > > }
> > > > set
> > > > {
> > > > _mstrValCssClass = value;
> > > > }
> > > > }
> > > >
> > > > This all seemed to work well when adding the composite dynamicallyexample,> composites> > > using
> > > > only one on a user control. My problem when I add two of the> > to> > > a
> > > > user control in the designer. Using the above property as ana> if> ValCssClass> > I> > > > set the ValCssClass of mycomposite1 to myclass1 and set the> > of> > mycomposite1> > > > mycomposite2 to myclass2, then the property also changes for> > static> > > > and viceversa. This only happens with the properties that utilize a> > > > variable, not the ones that are set per the first property example.
> > > >
> > > > Can anyone explain this and possibly provide a solution?
> > >
> > > Yes. Don't use statics. "static" means it's a member of the class, notsame> you> > > member of a class instance. Each time you drop your control on a page,> > > get a new instance of the control, but all instances will share the>> >> > > static members.
> > >
> > > So, "don't do that"!
> > > --
> > > John Saunders
> > > johnwsaundersiii at hotmail
> > >
> > >
> >
>
MS News \(MS ILM\) Guest
-
Teemu Keiski #8
Re: Composite Control Property Setting Problem
Hi,
you need to have System.ComponentModel namespace imported
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
[url]http://blogs.aspadvice.com/joteke[/url]
"MS News (MS ILM)" <sql_agentmans@hotmail.com> wrote in message
news:uySlzcfYEHA.3128@TK2MSFTNGP09.phx.gbl...textbox,> John,
> I tried that but its telling me that Description is not defined ???
> Am I missing an Import??
> I checked and can not figure it out.
>
> Thanks
>
>
> "John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
> news:%23y4zkjcYEHA.1048@tk2msftngp13.phx.gbl...> > Sorry, I meant:
> >
> > <Description("The text value")>
> >
> > --
> > John Saunders
> > johnwsaundersiii at hotmail
> >
> >
> > "MS News (MS ILM)" <sql_agentmans@hotmail.com> wrote in message
> > news:O$ZqAmZYEHA.808@tk2msftngp13.phx.gbl...> > > can I use the same attributes [Description("The text value"),
> > > etc... in VB.NET
> > >
> > > SA
> > >
> > > "John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
> > > news:OfwOrjVYEHA.3988@tk2msftngp13.phx.gbl...
> > > > "Alphonse Giambrone" <NOSPAMa-giam@example.invalid> wrote in message
> > > > news:ece3H%23TYEHA.2672@tk2msftngp13.phx.gbl...
> > > > > I have built a simple composite control that consists of aset/get> > > > > requiredfieldvalidator and rangevalidator.
> > > > >
> > > > > For properties that are unique to the individual control, Icontrol"),> want> > them> > > > > directly from the control as follows:
> > > > > [Description("The text value"),
> > > > > Bindable(true),
> > > > > Browsable(true),
> > > > > Category("TextBox"),
> > > > > DefaultValue("")]
> > > > > public string Text
> > > > > {
> > > > > get
> > > > > {
> > > > > EnsureChildControls();
> > > > > return txt1.Text;
> > > > > }
> > > > >
> > > > > set
> > > > > {
> > > > > EnsureChildControls();
> > > > > txt1.Text = value;
> > > > > }
> > > > > }
> > > > >
> > > > > For properties that are common to more than one control or that I> to> > > to
> > > > > additionally manipulate within the composite, I use private static
> > > > variables
> > > > > and then assign each control the variable's value before adding it> > > the
> > > > > controls collection:
> > > > >
> > > > > private static string _mstrValCssClass="";
> > > > >
> > > > > [Description("CssClass to apply to validator portion ofa>> or> > > > > Browsable(true),
> > > > > Category("Validators")]
> > > > > public string ValCssClass
> > > > > {
> > > > > get
> > > > > {
> > > > > return _mstrValCssClass;
> > > > > }
> > > > > set
> > > > > {
> > > > > _mstrValCssClass = value;
> > > > > }
> > > > > }
> > > > >
> > > > > This all seemed to work well when adding the composite dynamically> example,> > composites> > > > using
> > > > > only one on a user control. My problem when I add two of the> > > to
> > > > a
> > > > > user control in the designer. Using the above property as an> > if> > ValCssClass> > > I
> > > > > set the ValCssClass of mycomposite1 to myclass1 and set the> > > of
> > > > > mycomposite2 to myclass2, then the property also changes for
> > > mycomposite1
> > > > > and viceversa. This only happens with the properties that utilizeexample.> > > static
> > > > > variable, not the ones that are set per the first propertynot> > > > >
> > > > > Can anyone explain this and possibly provide a solution?
> > > >
> > > > Yes. Don't use statics. "static" means it's a member of the class,page,> a> > > > member of a class instance. Each time you drop your control on a> same> > you> > > > get a new instance of the control, but all instances will share the>> >> > > > static members.
> > > >
> > > > So, "don't do that"!
> > > > --
> > > > John Saunders
> > > > johnwsaundersiii at hotmail
> > > >
> > > >
> > >
> > >
> >
>
Teemu Keiski Guest
-
MS News \(MS ILM\) #9
Re: Composite Control Property Setting Problem
Thank you Sir, will try it.
"Teemu Keiski" <joteke@aspalliance.com> wrote in message
news:eabeBGoYEHA.3112@tk2msftngp13.phx.gbl...message> Hi,
>
> you need to have System.ComponentModel namespace imported
>
> --
> Teemu Keiski
> MCP, Microsoft MVP (ASP.NET), AspInsiders member
> ASP.NET Forum Moderator, AspAlliance Columnist
> [url]http://blogs.aspadvice.com/joteke[/url]
>
>
> "MS News (MS ILM)" <sql_agentmans@hotmail.com> wrote in message
> news:uySlzcfYEHA.3128@TK2MSFTNGP09.phx.gbl...> > John,
> > I tried that but its telling me that Description is not defined ???
> > Am I missing an Import??
> > I checked and can not figure it out.
> >
> > Thanks
> >
> >
> > "John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
> > news:%23y4zkjcYEHA.1048@tk2msftngp13.phx.gbl...> > > Sorry, I meant:
> > >
> > > <Description("The text value")>
> > >
> > > --
> > > John Saunders
> > > johnwsaundersiii at hotmail
> > >
> > >
> > > "MS News (MS ILM)" <sql_agentmans@hotmail.com> wrote in message
> > > news:O$ZqAmZYEHA.808@tk2msftngp13.phx.gbl...
> > > > can I use the same attributes [Description("The text value"),
> > > > etc... in VB.NET
> > > >
> > > > SA
> > > >
> > > > "John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
> > > > news:OfwOrjVYEHA.3988@tk2msftngp13.phx.gbl...
> > > > > "Alphonse Giambrone" <NOSPAMa-giam@example.invalid> wrote inI> textbox,> > > > > news:ece3H%23TYEHA.2672@tk2msftngp13.phx.gbl...
> > > > > > I have built a simple composite control that consists of a> set/get> > > > > > requiredfieldvalidator and rangevalidator.
> > > > > >
> > > > > > For properties that are unique to the individual control, I> > > them
> > > > > > directly from the control as follows:
> > > > > > [Description("The text value"),
> > > > > > Bindable(true),
> > > > > > Browsable(true),
> > > > > > Category("TextBox"),
> > > > > > DefaultValue("")]
> > > > > > public string Text
> > > > > > {
> > > > > > get
> > > > > > {
> > > > > > EnsureChildControls();
> > > > > > return txt1.Text;
> > > > > > }
> > > > > >
> > > > > > set
> > > > > > {
> > > > > > EnsureChildControls();
> > > > > > txt1.Text = value;
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > For properties that are common to more than one control or thatstatic> > want> > > > to
> > > > > > additionally manipulate within the composite, I use privateit> > > > > variables
> > > > > > and then assign each control the variable's value before addingdynamically> control"),> > to> > > > the
> > > > > > controls collection:
> > > > > >
> > > > > > private static string _mstrValCssClass="";
> > > > > >
> > > > > > [Description("CssClass to apply to validator portion of> >> > > > > > Browsable(true),
> > > > > > Category("Validators")]
> > > > > > public string ValCssClass
> > > > > > {
> > > > > > get
> > > > > > {
> > > > > > return _mstrValCssClass;
> > > > > > }
> > > > > > set
> > > > > > {
> > > > > > _mstrValCssClass = value;
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > This all seemed to work well when adding the compositeutilize> > or> > example,> > > > > using
> > > > > > only one on a user control. My problem when I add two of the
> > > composites
> > > > to
> > > > > a
> > > > > > user control in the designer. Using the above property as an> > > if
> > > > I
> > > > > > set the ValCssClass of mycomposite1 to myclass1 and set the
> > > ValCssClass
> > > > of
> > > > > > mycomposite2 to myclass2, then the property also changes for
> > > > mycomposite1
> > > > > > and viceversa. This only happens with the properties thatthe> a> example.> > > > static
> > > > > > variable, not the ones that are set per the first property> not> > > > > >
> > > > > > Can anyone explain this and possibly provide a solution?
> > > > >
> > > > > Yes. Don't use statics. "static" means it's a member of the class,> page,> > a> > > > > member of a class instance. Each time you drop your control on a> > > you
> > > > > get a new instance of the control, but all instances will share>> > same> >> > > > > static members.
> > > > >
> > > > > So, "don't do that"!
> > > > > --
> > > > > John Saunders
> > > > > johnwsaundersiii at hotmail
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
>
MS News \(MS ILM\) Guest
-
MS News \(MS ILM\) #10
Re: Composite Control Property Setting Problem
that was it thank you.
"Teemu Keiski" <joteke@aspalliance.com> wrote in message
news:eabeBGoYEHA.3112@tk2msftngp13.phx.gbl...message> Hi,
>
> you need to have System.ComponentModel namespace imported
>
> --
> Teemu Keiski
> MCP, Microsoft MVP (ASP.NET), AspInsiders member
> ASP.NET Forum Moderator, AspAlliance Columnist
> [url]http://blogs.aspadvice.com/joteke[/url]
>
>
> "MS News (MS ILM)" <sql_agentmans@hotmail.com> wrote in message
> news:uySlzcfYEHA.3128@TK2MSFTNGP09.phx.gbl...> > John,
> > I tried that but its telling me that Description is not defined ???
> > Am I missing an Import??
> > I checked and can not figure it out.
> >
> > Thanks
> >
> >
> > "John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
> > news:%23y4zkjcYEHA.1048@tk2msftngp13.phx.gbl...> > > Sorry, I meant:
> > >
> > > <Description("The text value")>
> > >
> > > --
> > > John Saunders
> > > johnwsaundersiii at hotmail
> > >
> > >
> > > "MS News (MS ILM)" <sql_agentmans@hotmail.com> wrote in message
> > > news:O$ZqAmZYEHA.808@tk2msftngp13.phx.gbl...
> > > > can I use the same attributes [Description("The text value"),
> > > > etc... in VB.NET
> > > >
> > > > SA
> > > >
> > > > "John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
> > > > news:OfwOrjVYEHA.3988@tk2msftngp13.phx.gbl...
> > > > > "Alphonse Giambrone" <NOSPAMa-giam@example.invalid> wrote inI> textbox,> > > > > news:ece3H%23TYEHA.2672@tk2msftngp13.phx.gbl...
> > > > > > I have built a simple composite control that consists of a> set/get> > > > > > requiredfieldvalidator and rangevalidator.
> > > > > >
> > > > > > For properties that are unique to the individual control, I> > > them
> > > > > > directly from the control as follows:
> > > > > > [Description("The text value"),
> > > > > > Bindable(true),
> > > > > > Browsable(true),
> > > > > > Category("TextBox"),
> > > > > > DefaultValue("")]
> > > > > > public string Text
> > > > > > {
> > > > > > get
> > > > > > {
> > > > > > EnsureChildControls();
> > > > > > return txt1.Text;
> > > > > > }
> > > > > >
> > > > > > set
> > > > > > {
> > > > > > EnsureChildControls();
> > > > > > txt1.Text = value;
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > For properties that are common to more than one control or thatstatic> > want> > > > to
> > > > > > additionally manipulate within the composite, I use privateit> > > > > variables
> > > > > > and then assign each control the variable's value before addingdynamically> control"),> > to> > > > the
> > > > > > controls collection:
> > > > > >
> > > > > > private static string _mstrValCssClass="";
> > > > > >
> > > > > > [Description("CssClass to apply to validator portion of> >> > > > > > Browsable(true),
> > > > > > Category("Validators")]
> > > > > > public string ValCssClass
> > > > > > {
> > > > > > get
> > > > > > {
> > > > > > return _mstrValCssClass;
> > > > > > }
> > > > > > set
> > > > > > {
> > > > > > _mstrValCssClass = value;
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > This all seemed to work well when adding the compositeutilize> > or> > example,> > > > > using
> > > > > > only one on a user control. My problem when I add two of the
> > > composites
> > > > to
> > > > > a
> > > > > > user control in the designer. Using the above property as an> > > if
> > > > I
> > > > > > set the ValCssClass of mycomposite1 to myclass1 and set the
> > > ValCssClass
> > > > of
> > > > > > mycomposite2 to myclass2, then the property also changes for
> > > > mycomposite1
> > > > > > and viceversa. This only happens with the properties thatthe> a> example.> > > > static
> > > > > > variable, not the ones that are set per the first property> not> > > > > >
> > > > > > Can anyone explain this and possibly provide a solution?
> > > > >
> > > > > Yes. Don't use statics. "static" means it's a member of the class,> page,> > a> > > > > member of a class instance. Each time you drop your control on a> > > you
> > > > > get a new instance of the control, but all instances will share>> > same> >> > > > > static members.
> > > > >
> > > > > So, "don't do that"!
> > > > > --
> > > > > John Saunders
> > > > > johnwsaundersiii at hotmail
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
>
MS News \(MS ILM\) Guest



Reply With Quote

