Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > DefaultValue not working (string)

Reply
Thread Tools

DefaultValue not working (string)

 
 
caviar
Guest
Posts: n/a
 
      09-17-2003
My defaultvalue attribute is not working. If i drop this control from
thetoolbox onto my page
the properties are empty. They keep being empty if i run this page on the
server. The only way to fix it is to initialize the property hidden internal
field whit the same value.

Is this by design or is something else wrong?

regards hj

public class WebChangePasswordControl : System.Web.UI.WebControls.WebControl


private string _title; //empty prop everywhere no def value
//private string _title = "Change Password"; //Now the property has an
default value..

[Bindable(false), Category("Appearance"),
DefaultValue("Change Password")]
public string Title
{
get{return _title;}
set{_title = value;}
}


 
Reply With Quote
 
 
 
 
Andrew
Guest
Posts: n/a
 
      09-17-2003
By Design.

The defaultValue attribute is a hint for the designer.
You need to put the same value there that you put into the variable when you
initialize it.

It should change how the design time html for the control is generated.

-Andrew

"caviar" <caviar-at-xsfourall.nl> wrote in message
news:eX#...
> My defaultvalue attribute is not working. If i drop this control from
> thetoolbox onto my page
> the properties are empty. They keep being empty if i run this page on the
> server. The only way to fix it is to initialize the property hidden

internal
> field whit the same value.
>
> Is this by design or is something else wrong?
>
> regards hj
>
> public class WebChangePasswordControl :

System.Web.UI.WebControls.WebControl
>
>
> private string _title; //empty prop everywhere no def value
> //private string _title = "Change Password"; //Now the property has an
> default value..
>
> [Bindable(false), Category("Appearance"),
> DefaultValue("Change Password")]
> public string Title
> {
> get{return _title;}
> set{_title = value;}
> }
>
>



 
Reply With Quote
 
 
 
 
caviar
Guest
Posts: n/a
 
      09-18-2003
Andrew wrote:
> By Design.
>
> The defaultValue attribute is a hint for the designer.
> You need to put the same value there that you put into the variable
> when you initialize it.
>
> It should change how the design time html for the control is
> generated.
>
> -Andrew


Ok thanx!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System.ComponentModel.DefaultValue doesn't work with user control =?Utf-8?B?QVNQIERldmVsb3Blcg==?= ASP .Net 0 09-12-2006 11:28 PM
ObjectDataSource (ODS) SelectParameter DefaultValue not being passed SJL ASP .Net 2 07-16-2006 03:45 PM
DefaultValue for Public Property of ASP.NET 2.0 UserControl not appearing in Properties Window Shadow Lynx ASP .Net Building Controls 1 02-28-2006 04:11 PM
Custom Control: DefaultValue attribute doesn't do anything dan ASP .Net 0 09-09-2005 08:45 AM
DefaultValue is not initialized Oleg Slyusarchuk ASP .Net Web Controls 5 05-21-2004 08:24 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57