asp.net后台动态改变样式后,点击button又改回原来的了
<asp:Repeater ID="RpJgxw" runat="server">
<HeaderTemplate>
<table style=" background-color:#c5c5c5; width:100%;" cellpadding="0" cellspacing="1">
<tr>
<td class="toptd">买入金额(万)</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<td><asp:Label ID="Label1" runat="server" ForeColor='<%#GetColor(Eval("StockZpb").ToString()) %>'
Text='<%# Eval("StockZpb")+"%"%>'></asp:Label></td>
</ItemTemplate>
<FooterTemplate>
</table></FooterTemplate>
</asp:Repeater>
//验证改变字体颜色
public System.Drawing.Color GetColor(string salary)
{
return Convert.ToDouble(salary) >= 0 ? System.Drawing.Color.FromName("#ff0000") : System.Drawing.Color.FromName("#30e02d");
}
protected void btnSummation_Click(object sender, EventArgs e)
{}
就是点击btnSummation_Click事件后Label的颜色又变成默认的了,该怎么搞?
------解决方案--------------------
了解下页面生命周期
你的回传首先会引发Page_Onload事件
------解决方案--------------------
看哪个时间先触发,哪些后触发