I have a DataList which contains several LinkButtons, which are used to
select a category in my application. I want the currently selected category
to use a different CSS class. Here is an example of the generated code for
one of the buttons:
<a
onclick="Unsele ctCategories(); datCategories_c tl00_lnkCategor y.className='Ca tegory_Selected ';"
id="datCategori es_ctl00_lnkCat egory" class="Category _Selected"
onmouseover="ca tegorystyle=thi s.className;thi s.className='Ca tegory_Selected ';"
onmouseout="thi s.className=cat egorystyle;"
href="javascrip t:__doPostBack( 'datCategories$ ctl00$lnkCatego ry','')"
style="display: block;">Compute rs/Electronics</a>
The onmouseover and onmouseout events (which I use to create a rollover to
switch between the selected/unselected style classes) work perfectly fine.
The onclick event, however, only partially works. The function
"UnselectCatego ries();" (which changes all the buttons to unselected) works
no problem. However, the statement that assigns a value to the className
property does not appear to be working. I have tried using both of the
following for this statement:
//Using the literal element id:
datCategories_c tl00_lnkCategor y.className='Ca tegory_Selected ';
//Using the keyword this:
this.className= 'Category_Selec ted';
I would prefer to use the keyword this so that I do not have to
programmaticall y generate the code, but neither one seemed to work. I am
confused by this, for multiple reasons:
1. UnselectCategor ies() is being called, so why isn't the other statement?
2. Note that the statement this.className= 'Category_Selec ted'; (I know it is
not the one in my example, but I tried it using both the element id and the
keyword this) is no different than the second statement in the onmouseover
event. What is making them different? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/