Solved

ASP.NET LisItem Attributes.Add does not work

Posted on 2004-08-03
3
290 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 500 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now