Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP.NET LisItem Attributes.Add does not work

Posted on 2004-08-03
3
Medium Priority
?
297 Views
Last Modified: 2008-01-09
I am binding a datasource to a CheckBoxList, and in the list of options I have a "None of these Apply to me" option, which is drawn from the datasource (i.e. so no, I cannot simply add a separate checkbox to do this, it must be implemented in the checkboxlist). What i tried to do is the following:

** the variable 'List' is the CheckBoxList
private override void OnPreRender(EventArgs e)
{
    //since the N/A option is always last
    ListItem na = List.Items[List.Items.Count - 1];
    na.Attributes.Add("onclick", "javascript:_doPostBack(//client id generated here));
}

--the onclick attribute is never added..this works flawlessly with a separate checkbox, why does the Attributes.Add method never work with ListItems?? This is extremely annoying, I can't understand why this would not have been implemented for listitems.
0
Comment
Question by:jookymaster
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
mantarae earned 2000 total points
ID: 11705117
Looks like there is a bug when it comes to adding any kind of attributes with the dropdownlist and radiobuttonlist, the article doesn't include checkbox list, but my guess is that it also affects the checkboxlist.  

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q309338
0
 

Author Comment

by:jookymaster
ID: 11705197
ahh, yea it looks like that same concept could be easily applied to a checkboxlist, thanks for finding that article for me, I hope they fixed that bug in ASP.NET v2.
0
 
LVL 7

Expert Comment

by:mantarae
ID: 11705365
I hope they fix that and all the other little bugs, without making new ones. :)  Good luck.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Integration Management Part 2
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question