maddhacker24
asked on
Trying to change the CSS of a DIV by clicking an asp:linkbutton which also will trigger an UpdatePanel in Codebehind C#
I'm just coming up to speed using .NET 4. I'm trying to change the background image of a div that surrounds my updatepanel. Whenever a user clicks on the asp:linkbuttons which are also my updatepanel triggers, the background image of the div should update. I have attached what I have now but its not working.
thanks for your help
thanks for your help
CSS
---------------------
#RightColumnContainer1
{
background: url(/images/rightcolumn/LeftTab.gif);
}
#RightColumnContainer2
{
background: url(/images/rightcolumn/MiddleTab.gif);
}
#RightColumnContainer3
{
background: url(/images/rightcolumn/RightTab.gif);
}
default.aspx
----------------------------------
<div id="RightColumnContainer1" runat="server">
<div><asp:LinkButton ID="lnkbtn1" runat="server" onclick="lnkbtn1_Click">Link 1</asp:LinkButton></div>
<div><asp:LinkButton ID="lnkbtn2" runat="server" onclick="lnkbtn2_Click">Link 2</asp:LinkButton></div>
<div><asp:LinkButton ID="lnkbtn3" runat="server" onclick="lnkbtn3_Click">Link 3</asp:LinkButton></div>
<asp:UpdatePanel ID="RightColumnUpdatePanel" runat="server">
<ContentTemplate>
<div>
Database results go here
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkbtn1"/>
<asp:AsyncPostBackTrigger ControlID="lnkbtn2"/>
<asp:AsyncPostBackTrigger ControlID="lnkbtn3"/>
</Triggers>
</asp:UpdatePanel>
</div>
C# Codebehind
---------------------------------
protected void lnkbtn1_Click(object sender, EventArgs e)
{
RightColumnContainer1.Attributes.CssStyle.Value = "RightColumnContainer1";
}
protected void lnkbtn2_Click(object sender, EventArgs e)
{
RightColumnContainer1.Attributes.CssStyle.Value = "RightColumnContainer2";
}
protected void lnkbtn3_Click(object sender, EventArgs e)
{
RightColumnContainer1.Attributes.CssStyle.Value = "RightColumnContainer3";
}
RightColumnContainer1.Attr ibutes.Css Style.Valu e = "RightColumnContainer1";
Change this code to
RightColumnContainer1.Attr ibutes.Add ("class", "RightColumnContainer1");
Change this code to
RightColumnContainer1.Attr
ASKER
Neither of those seem to work for me. hmmm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Works like a charm.
Thank you
Thank you
DaTribe