Reputation: 968
I am trying to dynamically change CSS class of panel in code behind.
I tried with DIV
with runat="server"
and div.Attributes["class"]="myClass"
. No success.
Then I went with asp panel. myPanel.cssClass = "myClass"
... no success.
I also tried AnthonyWJones's solution here: Best way to change CSS Classes from code With:
myPanel.RemoveCssClass("arrow_box");
myPanel.AddCssClass("arrow_boxMS");
Still no success.
The only thing I would like to change is arrow of the div
.
I helped myself with this (to generate CSS):
http://cssarrowplease.com/
My CSS:
.arrow_box, .arrow_boxMS
{
position: relative; /*background: #88b7d5;*/
border: 2px solid #c2e1f5;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
margin-top: 15px;
z-index: -1;
}
.arrow_box:after, .arrow_box:before
{
bottom: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute; /*pointer-events: none;*/
}
.arrow_box:after
{
border-color: rgba(136, 183, 213, 0);
border-bottom-color: #ffffff; /*#88b7d5;*/
border-width: 15px; /*SET height of smaller triangle within arrow. IMPORTANT bigger triangle is set in .arrow_box:before class*/
left: 8%;
margin-left: -15px;
}
.arrow_box:before
{
border-color: rgba(194, 225, 245, 0);
border-bottom-color: #c2e1f5;
border-width: 18px; /* SET height of bigger triangle - arrow IMPORTANT: difference between triangles must reflect how many pixels is border*/
left: 8%;
margin-left: -18px; /*if border thickness is changed adjust this to fit triangles*/
}
.arrow_boxMS:after, .arrow_boxMS:before
{
bottom: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute; /*pointer-events: none;*/
}
.arrow_boxMS:after
{
border-color: rgba(136, 183, 213, 0);
border-bottom-color: #ffffff; /*#88b7d5;*/
border-width: 15px; /*SET height of smaller triangle within arrow. IMPORTANT bigger triangle is set in .arrow_box:before class*/
left: 25%;
margin-left: -15px;
}
.arrow_boxMS:before
{
border-color: rgba(194, 225, 245, 0);
border-bottom-color: #c2e1f5;
border-width: 18px; /* SET height of bigger triangle - arrow IMPORTANT: difference between trinagles must reflect how many pixels is border*/
left: 25%;
margin-left: -18px; /*if border thickness is changed adjust this to fit triangles*/
}
The triangle just wouldn't change when button is clicked.
Any ideas?
EDIT:
<asp:UpdatePanel runat="server">
<ContentTemplate>
<table id="tblSelection">
<tr>
<td>
<asp:Button ID="btn1" Text="1" CssClass="button" ClientIDMode="Static"
runat="server" OnClick="btn1_Click" />
</td>
<td>
<asp:Button ID="btn2" Text="2" CssClass="button" ClientIDMode="Static"
runat="server" OnClick="btn2_Click" />
</td>
<td>
<asp:Button ID="btn3" Text="3" CssClass="button" runat="server" OnClick="btn3_Click" />
</td>
<td>
<asp:Button ID="btn4" Text="4" CssClass="button" runat="server"
OnClick="btn4_Click" />
</td>
<td>
<asp:Button ID="btn5" Text="5" CssClass="button" runat="server"
OnClick="btn5_Click" />
</td>
<td>
<asp:Button ID="btn5" Text="5" CssClass="button" runat="server" OnClick="btn5_Click" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Panel id="divDaySelection" runat="server">
<table id="tblDaySelection">
<tr>
<td>
<asp:CheckBox ID="cbAllDays" Text="All" runat="server"
oncheckedchanged="cbAllDays_CheckedChanged" AutoPostBack="true" />
</td>
<td>
<asp:CheckBox ID="cbMon" Text="Monday" runat="server" />
</td>
<td>
<asp:CheckBox ID="cbTue" Text="Tuesday" runat="server" />
</td>
<td>
<asp:CheckBox ID="cbWed" Text="Wednesday" runat="server" />
</td>
<td>
<asp:CheckBox ID="cbThu" Text="Thursday" runat="server" />
</td>
<td>
<asp:CheckBox ID="cbFri" Text="Friday" runat="server" />
</td>
<td>
<asp:CheckBox ID="cbSat" Text="Saturday" runat="server" />
</td>
<td>
<asp:CheckBox ID="cbSun" Text="Sunday" runat="server" />
</td>
</tr>
</table>
</asp:Panel>
Seems like updatepanel was problem since I am getting results right now ... now that I removed it.
Upvotes: 1
Views: 1622
Reputation: 968
As I (during editing post) and rocky figured it out the problem was that the panel was not in the updatepanel.
Technically all of my methods of changing CSS would work.
Upvotes: 0