DefaultValue attribute doesn't get set in a composite custom control

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

  1. #1

    Default DefaultValue attribute doesn't get set in a composite custom control



    I have a simple composite control with the following attributes:

    [
    Bindable(true),
    Category("Appearance"),
    DefaultValue("Enter name:"),
    Description("The text for the name label.")
    ]
    public string NameLabelText
    {
    get
    {
    EnsureChildControls();
    return nameLabel.Text;
    }
    set
    {
    EnsureChildControls();
    nameLabel.Text = value;
    }
    }

    However, when I drop the control on the page, the property is NOT set
    to the DefaultValue. It is blank.
    Can someone help me and explain why the default value doesn't work?

    Thanks

    J

    Jowita Guest

  2. Similar Questions and Discussions

    1. Composite Control with FormView property tag prefix attribute?
      Hi, I've developed a Composite control designed to take one FormView and one SqlDataSource as properties. I can add my composite control to the...
    2. Composite Control default style attribute
      I have a composite control that after dragging it onto the webform adds the following style attribute to the control: style="Z-INDEX: 101; LEFT:...
    3. Problems in Composite Custom Control
      Hi everybody, I am trying to a build an ASP .Net Custom Control(in C#) which will create a table ( with variable number of rows) dynamically based...
    4. Using XSLT in a custom composite control
      Yes, that says it all. I am trying to use XSLT to render the pre/post parts of the composite control in order to keep the look apart from the...
    5. Using Table control in a custom composite control. Control does not render properly in design time.
      All, I have written a very simple custom composite control that includes a control of type System.Web.UI.WebControls.Table. The control...
  3. #2

    Default Re: DefaultValue attribute doesn't get set in a composite custom control

    That behaviour is per default.

    all Standard classes have an if(value == null) implemented to catch
    that.
    the default value is for the Designer. so if you see the Properties of
    your dropped control(normally in the lower right pane), you see there
    the default values, that don't need to be set (so you have an code
    that is easier to read)

    cheers
    christoph


    On 14 Jun 2006 11:49:01 -0700, "Jowita" <jowi6@hotmail.com> wrote:
    >
    >
    >I have a simple composite control with the following attributes:
    >
    > [
    > Bindable(true),
    > Category("Appearance"),
    > DefaultValue("Enter name:"),
    > Description("The text for the name label.")
    > ]
    > public string NameLabelText
    > {
    > get
    > {
    > EnsureChildControls();
    > return nameLabel.Text;
    > }
    > set
    > {
    > EnsureChildControls();
    > nameLabel.Text = value;
    > }
    > }
    >
    >However, when I drop the control on the page, the property is NOT set
    >to the DefaultValue. It is blank.
    >Can someone help me and explain why the default value doesn't work?
    >
    >Thanks
    >
    >J
    Christoph Richter [AT] 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