我有一个 aspx 页面,默认设置为一种背景颜色。I need to be able to change it programmatically when a certain option of a radio button is selected. 我尝试设置表的 ID 字段,但似乎无法在我的 C# 代码隐藏文件中访问它。
我原来的表是:
<table id="tblSheet" runat="server" style="border-color: #FF9900; border-style: solid;
border-width: thin; width:100%; background-color: #99ccff;" cellspacing="4"
cellpadding="1">
不过,我没有在智能感知中看到 id。
编辑:
现在我可以在后面的代码中看到我的表格,我正在尝试实际更改背景颜色。这是我的单选按钮列表的代码:
<asp:RadioButtonList ID="rdoStatus" runat="server" AutoPostBack="true"
RepeatDirection="Horizontal" Visible="true"
OnSelectedIndexChanged="rdoStatus_OnSelectionChanged">
<asp:ListItem Value="181001" Text="Open"/>
<asp:ListItem Value="181002" Text="Closed" />
<asp:ListItem Value="181003" Text="Pending" />
</asp:RadioButtonList>
我遇到了在事件处理程序中设置的断点,但背景颜色在回发时没有改变。如果选择的项目是待定,那么我想将背景颜色更改为不同的颜色。如果他们将单选按钮更改为打开或关闭,那么我想确保背景颜色是默认颜色。
编辑 2:
我的事件处理程序中的代码非常简单:
if (rdoStatus.SelectedValue == "181003")
{
tblSheet.BgColor = "#ff9a9a";
}
else
{
tblSheet.BgColor = "#99ccff";
}