views:

1165

answers:

3

Hi All,

I have a scrolling div with Three linkbuttons and three differents divs. I need to apply CSS to active linkbutton as soon as button is clicked.The codes used by me are:

protected void btnNetwork_Click(object sender, EventArgs e)
    {
        this.btnForecast.CssClass = "li_1";
        this.btnBlog.CssClass = "li_2";
        this.btnNetwork.CssClass = "li_3_active";
        this.btnNetwork.ForeColor = System.Drawing.Color.White;
        lblMsg.Visible = false;
        BindGW("-----------------------------------");
        Forecast.Visible = false;
        Blog.Visible = false;
        Network.Visible = true;
    }

Thanks & Regards,

Khushi

+2  A: 

instead of using server side event use client side javascript event. try

$get('btnId').setAttribute("class", "some_class_name")

Pradeep Kumar Mishra
+1  A: 

You will not be able to dynamically change the CSS properties of elements by using post-back, which refreshes the page. Javascript must be used if you want to the change to happen immediately.

Bryan M.
A: 

Simple example..

Take one button, one label,

create one stylesheet and add class style1 as

body {
}

.style1 { color: #000080; }

write this simple code in button click event

protected void Button1_Click(object sender, EventArgs e) { this.Label1.CssClass = "style1"; }

Jags