Ask a Question related to ASP.NET Building Controls, Design and Development.
-
dolfandon@gmail.com #1
Default Values for Control Properties
I have a custom control that has a bunch of properties on it. I added
the DefaultValue attribute to it and it all seems to work fine with
showing up in the desiger and all. My question is, how do I get at that
default value at run time? If the user does not enter anything in the
designer then the entry never gets put in the control tag in the aspx
page and when I read the value it is empty. What is the magic to get
the default value or do I have to put it in the get of the property but
that seems clunky.
ASP.Net 2.0 for the record.
TIA
Don
dolfandon@gmail.com Guest
-
How do I validate the values entered for custom control properties?
I have a custom control with properties named MinValue, MaxValue, and Value (all of which I have assigned a DefaultValue design-time attribute). The... -
CreateChildControls() always has default values for properties
I am trying to develop a composite control that renders in a specific layout, depending on the value of the custom LabelPosition property. The... -
Specifying dynamic default values for properties in custom controls:
Hey guys, I have a custom int property in my control whose default value is dynamic, so I cannot specify a "DefaultValue" attribute. However, I... -
customizing attribute values for control properties
Is there somewhere an example on how to customize the serialization of control properties to aspx/ascx control attributes? I've implemented... -
how to set default values for non-basic type properties?
"Ben Schwehn" <b.schwehn@gmx.net> wrote in message news:pan.2003.09.21.20.08.15.169997@gmx.net... When you add a DefaultValue attribute to a... -
Brock Allen #2
Re: Default Values for Control Properties
Use reflection:
object[] attrs = typeof(YourClass).GetProperty("YourProperty").GetC ustomAttributes(typeof(DefaultPropertyAttribute),
false);
DefaultPropertyAttribute attr = attrs[0] as DefaultPropertyAttribute;
object value = attr.Value;
-Brock
[url]http://staff.develop.com/ballen[/url]
> I have a custom control that has a bunch of properties on it. I added
> the DefaultValue attribute to it and it all seems to work fine with
> showing up in the desiger and all. My question is, how do I get at
> that default value at run time? If the user does not enter anything in
> the designer then the entry never gets put in the control tag in the
> aspx page and when I read the value it is empty. What is the magic to
> get the default value or do I have to put it in the get of the
> property but that seems clunky.
>
> ASP.Net 2.0 for the record.
>
> TIA Don
>
Brock Allen Guest
-
MSDN #3
Re: Default Values for Control Properties
Brock,
I can't make your reflection example to work.
For example in a class called "Foo", a TextBox1 and to get the Width
What do you put , and is this good for FW 2.0?
Thanks
"Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
news:b8743b1b87d8c83ccdb7b4c296@msnews.microsoft.c om...> Use reflection:
>
> object[] attrs =
> typeof(YourClass).GetProperty("YourProperty").GetC ustomAttributes(typeof(DefaultPropertyAttribute),
> false);
> DefaultPropertyAttribute attr = attrs[0] as DefaultPropertyAttribute;
> object value = attr.Value;
>
> -Brock
> [url]http://staff.develop.com/ballen[/url]
>
>>>> I have a custom control that has a bunch of properties on it. I added
>> the DefaultValue attribute to it and it all seems to work fine with
>> showing up in the desiger and all. My question is, how do I get at
>> that default value at run time? If the user does not enter anything in
>> the designer then the entry never gets put in the control tag in the
>> aspx page and when I read the value it is empty. What is the magic to
>> get the default value or do I have to put it in the get of the
>> property but that seems clunky.
>>
>> ASP.Net 2.0 for the record.
>>
>> TIA Don
>>
>
MSDN Guest
-
MasterGaurav #4
Re: Default Values for Control Properties
Adding to Brock's comments...
Default Value attribute is only for the designer.
Runtime has nothing to do with it... it never makes use of it.
It if your responsibility to provide the value.
btw, where are you writing the the code that Brock provided?
Simplest way:
public PropertyType PropertyName
{
get
{
object obj = GetFromViewState...
if(obj != null)
{
(PropertyType) obj;
}
return DefaultValue_Of_PropertyName;
}
}
--
Cheers,
Gaurav Vaish
[url]http://mastergaurav.org[/url]
[url]http://www.edujini.in[/url]
-------------------------------
To Hell with Murphy's Law.. When things go broke, FIX Them
-------------------------------
MasterGaurav Guest
-
dolfandon@gmail.com #5
Re: Default Values for Control Properties
I ended up doing what Gaurav has (sort of) :)
[DefaultValue("defaultForProperty1")]
public string Property1
{
get
{
return (ValueNotInViewState() ? "defaultForProperty1" :
ValueInViewState);
}
set
{
SaveValueInViewState(value);
}
}
dolfandon@gmail.com Guest
-
Brock Allen #6
Re: Default Values for Control Properties
This works for me:
using System;
using System.ComponentModel;
public class Foo
{
[DefaultValue(5)]
public int Data
{
get
{
return 5;
}
}
}
class App
{
static void Main(string[] args)
{
object[] attrs =
typeof(Foo).GetProperty("Data").GetCustomAttribute s(typeof(DefaultValueAttribute),
false);
DefaultValueAttribute attr = attrs[0] as DefaultValueAttribute;
object val = attr.Value;
Console.WriteLine(val);
}
}
-Brock
[url]http://staff.develop.com/ballen[/url]
> Brock,
>
> I can't make your reflection example to work.
> For example in a class called "Foo", a TextBox1 and to get the Width
> What do you put , and is this good for FW 2.0?
> Thanks
>
> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
> news:b8743b1b87d8c83ccdb7b4c296@msnews.microsoft.c om...
>>> Use reflection:
>>
>> object[] attrs =
>> typeof(YourClass).GetProperty("YourProperty").GetC ustomAttributes(typ
>> eof(DefaultPropertyAttribute),
>> false);
>> DefaultPropertyAttribute attr = attrs[0] as DefaultPropertyAttribute;
>> object value = attr.Value;
>> -Brock
>> [url]http://staff.develop.com/ballen[/url]>>> I have a custom control that has a bunch of properties on it. I
>>> added the DefaultValue attribute to it and it all seems to work fine
>>> with showing up in the desiger and all. My question is, how do I get
>>> at that default value at run time? If the user does not enter
>>> anything in the designer then the entry never gets put in the
>>> control tag in the aspx page and when I read the value it is empty.
>>> What is the magic to get the default value or do I have to put it in
>>> the get of the property but that seems clunky.
>>>
>>> ASP.Net 2.0 for the record.
>>>
>>> TIA Don
>>>
Brock Allen Guest
-
MSDN #7
Re: Default Values for Control Properties
Brock,
First Thank you,
Second: When I drop a TextBox on a web form it has some default properties
like width and height.
Without assigning any values to the TextBox above, How do I get these
defaults?
Thank You,
SA
"Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
news:b8743b1bb928c83d9c32474ee2@msnews.microsoft.c om...> This works for me:
>
> using System;
> using System.ComponentModel;
>
> public class Foo
> {
> [DefaultValue(5)]
> public int Data
> {
> get
> {
> return 5;
> }
> }
> }
>
> class App
> {
> static void Main(string[] args)
> {
> object[] attrs =
> typeof(Foo).GetProperty("Data").GetCustomAttribute s(typeof(DefaultValueAttribute),
> false);
> DefaultValueAttribute attr = attrs[0] as DefaultValueAttribute;
> object val = attr.Value;
> Console.WriteLine(val);
> }
> }
>
>
> -Brock
> [url]http://staff.develop.com/ballen[/url]
>
>>>> Brock,
>>
>> I can't make your reflection example to work.
>> For example in a class called "Foo", a TextBox1 and to get the Width
>> What do you put , and is this good for FW 2.0?
>> Thanks
>>
>> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
>> news:b8743b1b87d8c83ccdb7b4c296@msnews.microsoft.c om...
>>>>> Use reflection:
>>>
>>> object[] attrs =
>>> typeof(YourClass).GetProperty("YourProperty").GetC ustomAttributes(typ
>>> eof(DefaultPropertyAttribute),
>>> false);
>>> DefaultPropertyAttribute attr = attrs[0] as DefaultPropertyAttribute;
>>> object value = attr.Value;
>>> -Brock
>>> [url]http://staff.develop.com/ballen[/url]
>>>> I have a custom control that has a bunch of properties on it. I
>>>> added the DefaultValue attribute to it and it all seems to work fine
>>>> with showing up in the desiger and all. My question is, how do I get
>>>> at that default value at run time? If the user does not enter
>>>> anything in the designer then the entry never gets put in the
>>>> control tag in the aspx page and when I read the value it is empty.
>>>> What is the magic to get the default value or do I have to put it in
>>>> the get of the property but that seems clunky.
>>>>
>>>> ASP.Net 2.0 for the record.
>>>>
>>>> TIA Don
>>>>
>
MSDN Guest
-
Brock Allen #8
Re: Default Values for Control Properties
In my sample code change "Foo" to "TextBox" and change "Data" to "Width".
-Brock
[url]http://staff.develop.com/ballen[/url]
> Brock,
>
> First Thank you,
> Second: When I drop a TextBox on a web form it has some default
> properties
> like width and height.
> Without assigning any values to the TextBox above, How do I get these
> defaults?
> Thank You,
>
> SA
>
> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
> news:b8743b1bb928c83d9c32474ee2@msnews.microsoft.c om...
>>> This works for me:
>>
>> using System;
>> using System.ComponentModel;
>> public class Foo
>> {
>> [DefaultValue(5)]
>> public int Data
>> {
>> get
>> {
>> return 5;
>> }
>> }
>> }
>> class App
>> {
>> static void Main(string[] args)
>> {
>> object[] attrs =
>> typeof(Foo).GetProperty("Data").GetCustomAttribute s(typeof(DefaultVal
>> ueAttribute),
>> false);
>> DefaultValueAttribute attr = attrs[0] as DefaultValueAttribute;
>> object val = attr.Value;
>> Console.WriteLine(val);
>> }
>> }
>> -Brock
>> [url]http://staff.develop.com/ballen[/url]>>> Brock,
>>>
>>> I can't make your reflection example to work.
>>> For example in a class called "Foo", a TextBox1 and to get the Width
>>> What do you put , and is this good for FW 2.0?
>>> Thanks
>>> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
>>> news:b8743b1b87d8c83ccdb7b4c296@msnews.microsoft.c om...
>>>
>>>> Use reflection:
>>>>
>>>> object[] attrs =
>>>> typeof(YourClass).GetProperty("YourProperty").GetC ustomAttributes(t
>>>> yp
>>>> eof(DefaultPropertyAttribute),
>>>> false);
>>>> DefaultPropertyAttribute attr = attrs[0] as
>>>> DefaultPropertyAttribute;
>>>> object value = attr.Value;
>>>> -Brock
>>>> [url]http://staff.develop.com/ballen[/url]
>>>>> I have a custom control that has a bunch of properties on it. I
>>>>> added the DefaultValue attribute to it and it all seems to work
>>>>> fine with showing up in the desiger and all. My question is, how
>>>>> do I get at that default value at run time? If the user does not
>>>>> enter anything in the designer then the entry never gets put in
>>>>> the control tag in the aspx page and when I read the value it is
>>>>> empty. What is the magic to get the default value or do I have to
>>>>> put it in the get of the property but that seems clunky.
>>>>>
>>>>> ASP.Net 2.0 for the record.
>>>>>
>>>>> TIA Don
>>>>>
Brock Allen Guest
-
MSDN #9
Re: Default Values for Control Properties
Used your exact code, still getting 0 (zero)
double wid = TextBox1.Width.Value;
object[] attrs =typeof(System.Web.UI.WebControls.TextBox).GetProp erty("Width").GetCustomAttributes(typeof(System.Co mponentModel.DefaultValueAttribute),false);
DefaultValueAttribute attr = attrs[0] as DefaultValueAttribute;
object val = attr.Value;
I guess this info is not available for web controls???????????????????????
Thank you Brock
SA
"Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message news:b8743b1bbbb8c83daaa0da946e@msnews.microsoft.c om...> In my sample code change "Foo" to "TextBox" and change "Data" to "Width".
>
> -Brock
> [url]http://staff.develop.com/ballen[/url]
>
>>>> Brock,
>>
>> First Thank you,
>> Second: When I drop a TextBox on a web form it has some default
>> properties
>> like width and height.
>> Without assigning any values to the TextBox above, How do I get these
>> defaults?
>> Thank You,
>>
>> SA
>>
>> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
>> news:b8743b1bb928c83d9c32474ee2@msnews.microsoft.c om...
>>>>> This works for me:
>>>
>>> using System;
>>> using System.ComponentModel;
>>> public class Foo
>>> {
>>> [DefaultValue(5)]
>>> public int Data
>>> {
>>> get
>>> {
>>> return 5;
>>> }
>>> }
>>> }
>>> class App
>>> {
>>> static void Main(string[] args)
>>> {
>>> object[] attrs =
>>> typeof(Foo).GetProperty("Data").GetCustomAttribute s(typeof(DefaultVal
>>> ueAttribute),
>>> false);
>>> DefaultValueAttribute attr = attrs[0] as DefaultValueAttribute;
>>> object val = attr.Value;
>>> Console.WriteLine(val);
>>> }
>>> }
>>> -Brock
>>> [url]http://staff.develop.com/ballen[/url]
>>>> Brock,
>>>>
>>>> I can't make your reflection example to work.
>>>> For example in a class called "Foo", a TextBox1 and to get the Width
>>>> What do you put , and is this good for FW 2.0?
>>>> Thanks
>>>> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
>>>> news:b8743b1b87d8c83ccdb7b4c296@msnews.microsoft.c om...
>>>>
>>>>> Use reflection:
>>>>>
>>>>> object[] attrs =
>>>>> typeof(YourClass).GetProperty("YourProperty").GetC ustomAttributes(t
>>>>> yp
>>>>> eof(DefaultPropertyAttribute),
>>>>> false);
>>>>> DefaultPropertyAttribute attr = attrs[0] as
>>>>> DefaultPropertyAttribute;
>>>>> object value = attr.Value;
>>>>> -Brock
>>>>> [url]http://staff.develop.com/ballen[/url]
>>>>>> I have a custom control that has a bunch of properties on it. I
>>>>>> added the DefaultValue attribute to it and it all seems to work
>>>>>> fine with showing up in the desiger and all. My question is, how
>>>>>> do I get at that default value at run time? If the user does not
>>>>>> enter anything in the designer then the entry never gets put in
>>>>>> the control tag in the aspx page and when I read the value it is
>>>>>> empty. What is the magic to get the default value or do I have to
>>>>>> put it in the get of the property but that seems clunky.
>>>>>>
>>>>>> ASP.Net 2.0 for the record.
>>>>>>
>>>>>> TIA Don
>>>>>>
>MSDN Guest
-
Brock Allen #10
Re: Default Values for Control Properties
Does the array have zero or one element in it? If it has one element, then
that's telling you the DefaultValue attribute has been appliied to the Width
proeprty and the default value is "" (the empty string). Looking with reflector,
that's what I'm expecting:
[WebCategory("Layout"), DefaultValue(typeof(Unit), ""), WebSysDescription("WebControl_Width")]
public virtual Unit Width
{
get
{
if (!this.ControlStyleCreated)
{
return Unit.Empty;
}
return this.ControlStyle.Width;
}
set
{
this.ControlStyle.Width = value;
}
}
-Brock
[url]http://staff.develop.com/ballen[/url]
> Used your exact code, still getting 0 (zero)
>
> double wid = TextBox1.Width.Value;
> object[] attrs
> =typeof(System.Web.UI.WebControls.TextBox).GetProp erty("Width").GetCus
> t
> omAttributes(typeof(System.ComponentModel.DefaultV alueAttribute),false
> );
> DefaultValueAttribute attr = attrs[0] as DefaultValueAttribute;
> object val = attr.Value;
> I guess this info is not available for web
> controls???????????????????????
>
> Thank you Brock
> SA
> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
> news:b8743b1bbbb8c83daaa0da946e@msnews.microsoft.c om...
>> "Width".>> In my sample code change "Foo" to "TextBox" and change "Data" to
>>
>> typeof(Foo).GetProperty("Data").GetCustomAttribute s(typeof(DefaultVal>> -Brock
>> [url]http://staff.develop.com/ballen[/url]>>> Brock,
>>>
>>> First Thank you,
>>> Second: When I drop a TextBox on a web form it has some default
>>> properties
>>> like width and height.
>>> Without assigning any values to the TextBox above, How do I get
>>> these
>>> defaults?
>>> Thank You,
>>> SA
>>>
>>> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
>>> news:b8743b1bb928c83d9c32474ee2@msnews.microsoft.c om...
>>>
>>>> This works for me:
>>>>
>>>> using System;
>>>> using System.ComponentModel;
>>>> public class Foo
>>>> {
>>>> [DefaultValue(5)]
>>>> public int Data
>>>> {
>>>> get
>>>> {
>>>> return 5;
>>>> }
>>>> }
>>>> }
>>>> class App
>>>> {
>>>> static void Main(string[] args)
>>>> {
>>>> object[] attrs =
>> Width>>>> ueAttribute),
>>>> false);
>>>> DefaultValueAttribute attr = attrs[0] as DefaultValueAttribute;
>>>> object val = attr.Value;
>>>> Console.WriteLine(val);
>>>> }
>>>> }
>>>> -Brock
>>>> [url]http://staff.develop.com/ballen[/url]
>>>>> Brock,
>>>>>
>>>>> I can't make your reflection example to work.
>>>>> For example in a class called "Foo", a TextBox1 and to get the
>> typeof(YourClass).GetProperty("YourProperty").GetC ustomAttributes(t>>>>> What do you put , and is this good for FW 2.0?
>>>>> Thanks
>>>>> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
>>>>> news:b8743b1b87d8c83ccdb7b4c296@msnews.microsoft.c om...
>>>>>> Use reflection:
>>>>>>
>>>>>> object[] attrs =
>>>>>>
>>>>>>> yp
>>>>>> eof(DefaultPropertyAttribute),
>>>>>> false);
>>>>>> DefaultPropertyAttribute attr = attrs[0] as
>>>>>> DefaultPropertyAttribute;
>>>>>> object value = attr.Value;
>>>>>> -Brock
>>>>>> [url]http://staff.develop.com/ballen[/url]
>>>>>>> I have a custom control that has a bunch of properties on it. I
>>>>>>> added the DefaultValue attribute to it and it all seems to work
>>>>>>> fine with showing up in the desiger and all. My question is, how
>>>>>>> do I get at that default value at run time? If the user does not
>>>>>>> enter anything in the designer then the entry never gets put in
>>>>>>> the control tag in the aspx page and when I read the value it is
>>>>>>> empty. What is the magic to get the default value or do I have
>>>>>>> to put it in the get of the property but that seems clunky.
>>>>>>>
>>>>>>> ASP.Net 2.0 for the record.
>>>>>>>
>>>>>>> TIA Don
>>>>>>>
Brock Allen Guest
-
MSDN #11
Re: Default Values for Control Properties
Brock,
We might be thinking about different things here. may be not?
when you drop a TextBox control on the Designer it has a default width,
height etc...
How do you get that default width.
Microsoft must be getting this default from some place ( meta data of
defaults etc.. )
I was hoping that your code can tell me how to get this default value.
Microsoft must be baking this someplace.
If the default is "" String.Empty(); then how does it show at design and run
time at some width greater than 50px ++ ; ??
Are we on the right page?
Thank you Brock
SA
"Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
news:b8743b1bc0d8c83db42c39a49c@msnews.microsoft.c om...> Does the array have zero or one element in it? If it has one element, then
> that's telling you the DefaultValue attribute has been appliied to the
> Width proeprty and the default value is "" (the empty string). Looking
> with reflector, that's what I'm expecting:
>
> [WebCategory("Layout"), DefaultValue(typeof(Unit), ""),
> WebSysDescription("WebControl_Width")]
> public virtual Unit Width
> {
> get
> {
> if (!this.ControlStyleCreated)
> {
> return Unit.Empty;
> }
> return this.ControlStyle.Width;
> }
> set
> {
> this.ControlStyle.Width = value;
> }
> }
>
>
> -Brock
> [url]http://staff.develop.com/ballen[/url]
>
>>>> Used your exact code, still getting 0 (zero)
>>
>> double wid = TextBox1.Width.Value;
>> object[] attrs
>> =typeof(System.Web.UI.WebControls.TextBox).GetProp erty("Width").GetCus
>> t
>> omAttributes(typeof(System.ComponentModel.DefaultV alueAttribute),false
>> );
>> DefaultValueAttribute attr = attrs[0] as DefaultValueAttribute;
>> object val = attr.Value;
>> I guess this info is not available for web
>> controls???????????????????????
>>
>> Thank you Brock
>> SA
>> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
>> news:b8743b1bbbb8c83daaa0da946e@msnews.microsoft.c om...
>>>> "Width".>>> In my sample code change "Foo" to "TextBox" and change "Data" to
>>>
>>>> typeof(Foo).GetProperty("Data").GetCustomAttribute s(typeof(DefaultVal>>> -Brock
>>> [url]http://staff.develop.com/ballen[/url]
>>>> Brock,
>>>>
>>>> First Thank you,
>>>> Second: When I drop a TextBox on a web form it has some default
>>>> properties
>>>> like width and height.
>>>> Without assigning any values to the TextBox above, How do I get
>>>> these
>>>> defaults?
>>>> Thank You,
>>>> SA
>>>>
>>>> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
>>>> news:b8743b1bb928c83d9c32474ee2@msnews.microsoft.c om...
>>>>
>>>>> This works for me:
>>>>>
>>>>> using System;
>>>>> using System.ComponentModel;
>>>>> public class Foo
>>>>> {
>>>>> [DefaultValue(5)]
>>>>> public int Data
>>>>> {
>>>>> get
>>>>> {
>>>>> return 5;
>>>>> }
>>>>> }
>>>>> }
>>>>> class App
>>>>> {
>>>>> static void Main(string[] args)
>>>>> {
>>>>> object[] attrs =
>>>> Width>>>>> ueAttribute),
>>>>> false);
>>>>> DefaultValueAttribute attr = attrs[0] as DefaultValueAttribute;
>>>>> object val = attr.Value;
>>>>> Console.WriteLine(val);
>>>>> }
>>>>> }
>>>>> -Brock
>>>>> [url]http://staff.develop.com/ballen[/url]
>>>>>> Brock,
>>>>>>
>>>>>> I can't make your reflection example to work.
>>>>>> For example in a class called "Foo", a TextBox1 and to get the
>>>> typeof(YourClass).GetProperty("YourProperty").GetC ustomAttributes(t>>>>>> What do you put , and is this good for FW 2.0?
>>>>>> Thanks
>>>>>> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
>>>>>> news:b8743b1b87d8c83ccdb7b4c296@msnews.microsoft.c om...
>>>>>>> Use reflection:
>>>>>>>
>>>>>>> object[] attrs =
>>>>>>>
>>>>>>>>> yp
>>>>>>> eof(DefaultPropertyAttribute),
>>>>>>> false);
>>>>>>> DefaultPropertyAttribute attr = attrs[0] as
>>>>>>> DefaultPropertyAttribute;
>>>>>>> object value = attr.Value;
>>>>>>> -Brock
>>>>>>> [url]http://staff.develop.com/ballen[/url]
>>>>>>>> I have a custom control that has a bunch of properties on it. I
>>>>>>>> added the DefaultValue attribute to it and it all seems to work
>>>>>>>> fine with showing up in the desiger and all. My question is, how
>>>>>>>> do I get at that default value at run time? If the user does not
>>>>>>>> enter anything in the designer then the entry never gets put in
>>>>>>>> the control tag in the aspx page and when I read the value it is
>>>>>>>> empty. What is the magic to get the default value or do I have
>>>>>>>> to put it in the get of the property but that seems clunky.
>>>>>>>>
>>>>>>>> ASP.Net 2.0 for the record.
>>>>>>>>
>>>>>>>> TIA Don
>>>>>>>>
>
MSDN Guest
-
Gaurav Vaish \(EduJini.IN\) #12
Re: Default Values for Control Properties
>I ended up doing what Gaurav has (sort of) :)
:-)
--
Happy Hacking,
Gaurav Vaish
[url]http://www.mastergaurav.org[/url]
[url]http://www.edujini.in[/url]
-------------------
>
> [DefaultValue("defaultForProperty1")]
> public string Property1
> {
> get
> {
> return (ValueNotInViewState() ? "defaultForProperty1" :
> ValueInViewState);
> }
> set
> {
> SaveValueInViewState(value);
> }
> }
>
Gaurav Vaish \(EduJini.IN\) Guest



Reply With Quote

