[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Can't get default values working!

Jason Butera

1/8/2003 11:29:00 PM

I want to have default values for my server control properties, but I
can't seem to get them to work. My typical property set is like this:

Dim m_Maximumvalue As Integer = 999999999
<defaultvalue(999999999)> Public Property MaximumValue As Integer
Get
Return m_Maximumvalue
End Get
Set(ByVal Value As Integer)
m_Maximumvalue = Value
End Set
End Property

Unfortunately, this isn't working...why not?

Also, how do you set the defaults for date datatypes, the following
doesn't work?
Dim m_Maximumvalue As Date = "12/31/9999"
<defaultvalue("12/31/9999"))> Public Property MaximumValue As Date
Get
Return m_Maximumvalue
End Get
Set(ByVal Value As Date)
m_Maximumvalue = Value
End Set
End Property
????????
3 Answers

Ajay

1/9/2003 2:17:00 AM

0

Are your default values same as the initial value of your property (probably
being initialized in your constructor) ?

For datetime do this ...

C# -> [DefaultValue(typeof(DateTime),"12/31/9998")]

HTH,
Ajay

"Jason Butera" <jjbutera@hotmail.com> wrote in message
news:509b03ca.0301081426.6fca6ad4@posting.google.com...
> I want to have default values for my server control properties, but I
> can't seem to get them to work. My typical property set is like this:
>
> Dim m_Maximumvalue As Integer = 999999999
> <defaultvalue(999999999)> Public Property MaximumValue As Integer
> Get
> Return m_Maximumvalue
> End Get
> Set(ByVal Value As Integer)
> m_Maximumvalue = Value
> End Set
> End Property
>
> Unfortunately, this isn't working...why not?
>
> Also, how do you set the defaults for date datatypes, the following
> doesn't work?
> Dim m_Maximumvalue As Date = "12/31/9999"
> <defaultvalue("12/31/9999"))> Public Property MaximumValue As Date
> Get
> Return m_Maximumvalue
> End Get
> Set(ByVal Value As Date)
> m_Maximumvalue = Value
> End Set
> End Property
> ????????


Victor Garcia Aprea [MVP]

1/9/2003 9:00:00 AM

0

Hi Jason,

The DefaultValue attribute is not meant to set the initial value of your
property, you should do so in for example, the class constructor.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.


"Jason Butera" <jjbutera@hotmail.com> wrote in message
news:509b03ca.0301081426.6fca6ad4@posting.google.com...
> I want to have default values for my server control properties, but I
> can't seem to get them to work. My typical property set is like this:
>
> Dim m_Maximumvalue As Integer = 999999999
> <defaultvalue(999999999)> Public Property MaximumValue As Integer
> Get
> Return m_Maximumvalue
> End Get
> Set(ByVal Value As Integer)
> m_Maximumvalue = Value
> End Set
> End Property
>
> Unfortunately, this isn't working...why not?
>
> Also, how do you set the defaults for date datatypes, the following
> doesn't work?
> Dim m_Maximumvalue As Date = "12/31/9999"
> <defaultvalue("12/31/9999"))> Public Property MaximumValue As Date
> Get
> Return m_Maximumvalue
> End Get
> Set(ByVal Value As Date)
> m_Maximumvalue = Value
> End Set
> End Property
> ????????


Jason Butera

1/21/2003 10:06:00 PM

0

Can you give me an example of how I'd do that? Thanks.

"Victor Garcia Aprea [MVP]" <vga@NOobiesSPAM.com> wrote in message news:<#aI32S7tCHA.2280@TK2MSFTNGP11>...
> Hi Jason,
>
> The DefaultValue attribute is not meant to set the initial value of your
> property, you should do so in for example, the class constructor.
>
> --
> Victor Garcia Aprea
> Microsoft MVP | ASP.NET
> To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
> and not by private mail.
>
>
> "Jason Butera" <jjbutera@hotmail.com> wrote in message
> news:509b03ca.0301081426.6fca6ad4@posting.google.com...
> > I want to have default values for my server control properties, but I
> > can't seem to get them to work. My typical property set is like this:
> >
> > Dim m_Maximumvalue As Integer = 999999999
> > <defaultvalue(999999999)> Public Property MaximumValue As Integer
> > Get
> > Return m_Maximumvalue
> > End Get
> > Set(ByVal Value As Integer)
> > m_Maximumvalue = Value
> > End Set
> > End Property
> >
> > Unfortunately, this isn't working...why not?
> >
> > Also, how do you set the defaults for date datatypes, the following
> > doesn't work?
> > Dim m_Maximumvalue As Date = "12/31/9999"
> > <defaultvalue("12/31/9999"))> Public Property MaximumValue As Date
> > Get
> > Return m_Maximumvalue
> > End Get
> > Set(ByVal Value As Date)
> > m_Maximumvalue = Value
> > End Set
> > End Property
> > ????????