ListItem.AddAttributes has no affect?

Discussion in 'ASP .Net Web Controls' started by PV, Mar 1, 2004.

  1. PV

    PV Guest

    I am trying to add some attributes to a DropDownList's list items.

    For Example
    dropdownList1.Items[0].Attributes.Add("myExpandoProperty",
    "myExpandoValue");

    I would expect then the rendered html to look like:

    <select name="dropdownList1" id="dropdownList1">
    <option value="test" myExpandoProperty="myExpandoValue">test</option>
    </select>

    However, the expando property does not show up. What's the point of having
    an attributes collection if it does not get rendered in the HTML!?

    Any idea how to do this?
    PV, Mar 1, 2004
    #1
    1. Advertising

  2. That's a well documented bug. There is currently no work around.

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "PV" <> wrote in message
    news:uwxCzp9$...
    > I am trying to add some attributes to a DropDownList's list items.
    >
    > For Example
    > dropdownList1.Items[0].Attributes.Add("myExpandoProperty",
    > "myExpandoValue");
    >
    > I would expect then the rendered html to look like:
    >
    > <select name="dropdownList1" id="dropdownList1">
    > <option value="test" myExpandoProperty="myExpandoValue">test</option>
    > </select>
    >
    > However, the expando property does not show up. What's the point of

    having
    > an attributes collection if it does not get rendered in the HTML!?
    >
    > Any idea how to do this?
    >
    >
    Alvin Bruney [MVP], Mar 1, 2004
    #2
    1. Advertising

  3. PV

    PV Guest

    And as an added bonus, it is a sealed class. So I can't inherit from the
    thing and implement it properly. Just great.

    Any chance of a hotfix?

    As it stands, it looks like I would have to implement my own DropDownList
    control just so that I can add my own correctly implemented ListItem objects
    to it (at least dropdownlist isn't sealed). Would that be a correct
    assesment?

    "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    news:uuoCrH%23$...
    > That's a well documented bug. There is currently no work around.
    >
    > --
    > Regards,
    > Alvin Bruney [ASP.NET MVP]
    > Got tidbits? Get it here...
    > http://tinyurl.com/3he3b
    > "PV" <> wrote in message
    > news:uwxCzp9$...
    > > I am trying to add some attributes to a DropDownList's list items.
    > >
    > > For Example
    > > dropdownList1.Items[0].Attributes.Add("myExpandoProperty",
    > > "myExpandoValue");
    > >
    > > I would expect then the rendered html to look like:
    > >
    > > <select name="dropdownList1" id="dropdownList1">
    > > <option value="test" myExpandoProperty="myExpandoValue">test</option>
    > > </select>
    > >
    > > However, the expando property does not show up. What's the point of

    > having
    > > an attributes collection if it does not get rendered in the HTML!?
    > >
    > > Any idea how to do this?
    > >
    > >

    >
    >
    PV, Mar 2, 2004
    #3
  4. You may be able to write to it if you replace the listbox with a select tag.
    I've not tried it but i suspect it is better than waiting for a hot fix. The
    next hotfix is whidbey which is a while away.

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "PV" <> wrote in message
    news:...
    > And as an added bonus, it is a sealed class. So I can't inherit from the
    > thing and implement it properly. Just great.
    >
    > Any chance of a hotfix?
    >
    > As it stands, it looks like I would have to implement my own DropDownList
    > control just so that I can add my own correctly implemented ListItem

    objects
    > to it (at least dropdownlist isn't sealed). Would that be a correct
    > assesment?
    >
    > "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    > news:uuoCrH%23$...
    > > That's a well documented bug. There is currently no work around.
    > >
    > > --
    > > Regards,
    > > Alvin Bruney [ASP.NET MVP]
    > > Got tidbits? Get it here...
    > > http://tinyurl.com/3he3b
    > > "PV" <> wrote in message
    > > news:uwxCzp9$...
    > > > I am trying to add some attributes to a DropDownList's list items.
    > > >
    > > > For Example
    > > > dropdownList1.Items[0].Attributes.Add("myExpandoProperty",
    > > > "myExpandoValue");
    > > >
    > > > I would expect then the rendered html to look like:
    > > >
    > > > <select name="dropdownList1" id="dropdownList1">
    > > > <option value="test"

    myExpandoProperty="myExpandoValue">test</option>
    > > > </select>
    > > >
    > > > However, the expando property does not show up. What's the point of

    > > having
    > > > an attributes collection if it does not get rendered in the HTML!?
    > > >
    > > > Any idea how to do this?
    > > >
    > > >

    > >
    > >

    >
    >
    Alvin Bruney [MVP], Mar 2, 2004
    #4
    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. Mad Scientist Jr
    Replies:
    2
    Views:
    431
    Mad Scientist Jr
    Jun 29, 2004
  2. Jim in Arizona
    Replies:
    7
    Views:
    906
    Badass Scotsman
    Nov 22, 2006
  3. Replies:
    2
    Views:
    528
  4. setAttribute has no affect

    , Jun 6, 2006, in forum: Javascript
    Replies:
    4
    Views:
    112
    Richard Cornford
    Jun 6, 2006
  5. Replies:
    0
    Views:
    129
Loading...

Share This Page