DefaultValue not working (string)

Discussion in 'ASP .Net Building Controls' started by caviar, Sep 17, 2003.

  1. caviar

    caviar Guest

    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;}
    }
     
    caviar, Sep 17, 2003
    #1
    1. Advertising

  2. caviar

    Andrew Guest

    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;}
    > }
    >
    >
     
    Andrew, Sep 17, 2003
    #2
    1. Advertising

  3. caviar

    caviar Guest

    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!
     
    caviar, Sep 18, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dan
    Replies:
    0
    Views:
    540
  2. SJL
    Replies:
    2
    Views:
    2,349
  3. =?Utf-8?B?QVNQIERldmVsb3Blcg==?=

    System.ComponentModel.DefaultValue doesn't work with user control

    =?Utf-8?B?QVNQIERldmVsb3Blcg==?=, Sep 13, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,675
    =?Utf-8?B?QVNQIERldmVsb3Blcg==?=
    Sep 13, 2006
  4. Shadow Lynx
    Replies:
    1
    Views:
    197
  5. Oleg Slyusarchuk

    DefaultValue is not initialized

    Oleg Slyusarchuk, May 18, 2004, in forum: ASP .Net Web Controls
    Replies:
    5
    Views:
    196
    Robert Koritnik
    May 21, 2004
Loading...

Share This Page