Changing Font-Size of a Hyperlink inside the Repeater Control

This was a question asked today on the ASP.NET Forums. Although you might be wondering that hey I can just use "this.style.font-size:Large" and it will work. For some reason it does not work and the work around is to create a CSS class and define the properties in that class. Take a look at the code below:

     
    <style type="text/css">

.link_color{color:blue;}
.hover_color{color:red;}

.hoverIn_Font { font-size:25px; } 
.hoverOut_Font { font-size:12px; }

    </style>

And here is the Code Behind:

 protected void rep1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {        

        
if (e.Item.ItemType == ListItemType.Item ||
            e.Item.ItemType == ListItemType.AlternatingItem)
        {
            HyperLink link = e.Item.FindControl("hlLink") 
as HyperLink;

            link.Attributes.Add("onmouseover", "this.className='hoverIn_Font'");
            link.Attributes.Add("onmouseout", "this.className='hoverOut_Font'"); 
        }
    }

 

powered by IMHO 1.3

Print | posted @ Thursday, June 29, 2006 3:43 PM

Twitter