DefaultValue not working (string)

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default DefaultValue not working (string)

    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 Guest

  2. Similar Questions and Discussions

    1. #40792 [NEW]: Wish: Function array_get(&$mixed, $key, $defaultvalue)
      From: t dot kloppenburg at billiton dot de Operating system: Linux PHP version: 5.2.1 PHP Bug Type: Feature/Change Request...
    2. DefaultValue attribute doesn't get set in a composite custom control
      I have a simple composite control with the following attributes: public string NameLabelText { get { EnsureChildControls(); return...
    3. DefaultValue for Public Property of ASP.NET 2.0 UserControl not appearing in Properties Window
      First, I'm using Visual Web Developer 2005 Express Edition, which I hope is exactly the same as Visual Studio 2005 minus a bunch of useful...
    4. Working OLE DB string for an Access DB
      Hi All This may be striaght forward for most, but I am really getting in a tiswas with it. I have been to the able consulting,...
    5. String matching not working
      Hi, I am quite new to Perl. I have several sets of data and within each individual file news stories are seperated using ========. My goal is...
  3. #2

    Default Re: DefaultValue not working (string)

    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#zRMQfDHA.368@TK2MSFTNGP12.phx.gbl...
    > 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 Guest

  4. #3

    Default Re: DefaultValue not working (string)

    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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139