怎样设置表格的背景编程运行一个asp.net页面时? [英] How do I set a table background programmatically while running an asp.net page?

查看:76
本文介绍了怎样设置表格的背景编程运行一个asp.net页面时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有有一个背景色为默认的aspx页面。我需要的是选择的单选按钮的特定选择时,能够以编程改变它。我试着设置表的ID字段,但我似乎无法访问它的隐藏文件我的C#code。

我原来的表是:

 <表ID =tblSheet=服务器的风格=边框颜色:#FF9900;边框样式:固体;
边框宽度:薄;宽度:100%;背景颜色:#99CCFF;CELLSPACING =4
CELLPADDING =1>

我看不到我的智能感知的ID,虽然。

编辑:

现在,我可以看到在我的code背着我的表,我想真正改变背景颜色。这里是code为我的单选按钮列表:

 < ASP:RadioButtonList的ID =rdoStatus=服务器的AutoPostBack =真
RepeatDirection =水平可见=真
OnSelectedIndexChanged =rdoStatus_OnSelectionChanged>
< ASP:ListItem的值=181001文本=打开/>
< ASP:ListItem的值=181002文本=关闭/>
< ASP:ListItem的值=181003文本=待定/>
< / ASP:RadioButtonList的>

我打我的事件处理程序设置断点,但背景颜色是不会改变的回发。如果选择的产品挂起,那么我想改变背景颜色,以不同的东西。如果他们改变了单选按钮来打开或关闭的话,我希望确保背景色为默认值。

编辑2:

在我的事件处理程序的code是非常简单的:

 如果(rdoStatus.SelectedValue ==181003)
{
  tblSheet.BgColor =#ff9a9a;
}
其他
{
  tblSheet.BgColor =#99CCFF
}


解决方案

我得到它的工作!

我改变了表如下(我删除了背景色):

 <表ID =tblSheet=服务器的风格=边框颜色:#FF9900;边框样式:固体;
边框宽度:薄;宽度:100%;CELLSPACING =4CELLPADDING =1>

然后在我的code后面,我在设定时,它在Page_Load背景色的不可以回发:

  tblSheet.Bgcolor =#99CCFF

瞧!在RadioButtonList和事件处理程序的相同的问题。回发是改变颜色回原来的。感谢大家的帮助!

I have an aspx page that has one background color as the default. I need to be able to change it programmatically when a certain option of a radio button is selected. I tried setting the ID field of the table, but I can't seem to access it in my C# code behind file.

My original table is:

<table id="tblSheet" runat="server" style="border-color: #FF9900; border-style: solid; 
border-width:  thin; width:100%; background-color: #99ccff;" cellspacing="4" 
cellpadding="1">

I don't see the id in my intellisense, though.

Edit:
Now that I can see my table in my code behind, I'm trying to actually change the background color. Here is the code for my radiobuttonlist:

<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>

I'm hitting the breakpoint I set in the event handler, but the background color is not changing on postback. If the item chosen is Pending, then I want to change the background color to something different. If they change the radio button to Open Or Closed, then I want to make sure the background color is the default.

Edit 2:
The code in my event handler is very simple:

if (rdoStatus.SelectedValue == "181003")
{
  tblSheet.BgColor = "#ff9a9a";
}
else
{
  tblSheet.BgColor = "#99ccff";
}

解决方案

I got it working!
I changed the table to the following (I removed the background-color):

<table id="tblSheet" runat="server" style="border-color: #FF9900; border-style: solid; 
border-width: thin; width:100%;" cellspacing="4" cellpadding="1">

Then in my code behind I set the background color in the Page_Load when it's not a postback:

tblSheet.Bgcolor = "#99ccff";

Voila! The radiobuttonlist and event handler are the same as in the question. The postback was changing the color back to the original. Thanks for everyone's help!

这篇关于怎样设置表格的背景编程运行一个asp.net页面时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆