Response.Write(div1.Style["BACKGROUND-COLOR"].ToString());<div id="div1" style="BACKGROUND-COLOR: silver" runat="server">dfsdfsdf </div>相关的看这个帮助CssStyleCollection
解决方案 »
- WPF程序中FrameWorkContentElement无法获取相关sender对象内容,求解答,谢谢
- js显示隐藏表格,但是点击按钮又隐藏了,如何能保持显示
- 点左边变右边.不用框架
- 怎样把10000转换为一萬!!!日期格式 转换成大写!!!
- IIS的虚拟目录以及asp.net制作web应用程序的发布
- 不能偵錯
- excel文件无法打开
- 关于添加引用
- asp.net的WebCustomControl希望设置一个属性在设计时的属性窗口中为combo型
- 为什么我的EXCEL拒绝访问
- 我做了一个用户控件,里面含一个DATAGRID,在一个ASPX页中,我引用了这个用户控件,并给那个DATAGRID添加一列“编辑”列,但是点击这一列
- 已经把数据导成excel后,如何让用户点击一按钮过后出现“保存文件“的对话框???
<div id="div1" runat="server"></div>
在.cs里:
protected System.Web.UI.HtmlControls.HtmlGenericControl div1;
Page_Load()等函数里:
div1.Attributes["bgcolor"] = "Wheat";
div1.InnerHtml= "kaokao";
protected System.Web.UI.HtmlControls.HtmlGenericControl div1;
protected System.Web.UI.HtmlControls.HtmlGenericControl Div1;加属性:
Div1.Style.Add("background-color","....");
取:
string s = Div1.Style["background-color"].ToString();
注意,分大小写的!
你去查查getsrcelement的用法
说是“未将对象设置到实例”。
这是怎么回事啊?
while (keys.MoveNext())
{
String key = (String)keys.Current;
string ss = key + "=" + Ninediv.Style[key] + "<br>";
}
试试看,就知道应该是用大写了。
string ss = Ninediv.Style["BACKGROUND-COLOR"] + "<br>";
protected System.Web.UI.HtmlControls.HtmlGenericControl Div1;
这句话是否在动态生成DIV的时候会自动写入cs文件呢?要是不行怎么做呢?
还有,要是在DIV中加了runat属性成为服务器节点,我还要在客户端对其进行操作
,移动,即改变style里面的位置属性,会不会产生不断刷屏的现象?
这个我就不知道了。
要是在DIV中加了runat属性成为服务器节点,我还要在客户端对其进行操作
,移动,即改变style里面的位置属性时,我倒是没有试过会不会刷屏,不过改变其颜色属性时倒不会刷屏。
<form runat=server id="form1">
<div id="abc" runat=server>
...
</form>在取数据的时候用
form1.FindControls["div"]
这样得到的是一个object,再转换成DIV就可以了,我用过动态生成radiobutton然后用这个方法得到值,可能是一样的吧,你可以试一下。
贴个具体动态生成的例子可以吗?
phoenixsbk(凤之泪痕)能把你 动态生成radiobutton并得到其属性值的代码贴出来让我学习一下吗?
谢谢!
贴个具体动态生成的例子可以吗?
phoenixsbk(凤之泪痕)能把你 动态生成radiobutton并得到其属性值的代码贴出来让我学习一下吗?
谢谢!
DataTable vote=db.ExecuteSingleQuery("select * from [vote] where vote_bbs="+bbsid,"votetable");
foreach(DataRow myrow in vote.Rows)
{
total+=Int32.Parse(myrow["vote_number"].ToString());
}
if(total==0)
{total=1;}
int color=0;
foreach(DataRow voterow in vote.Rows)
{
TableRow mainvoterow=new TableRow();
TableCell mainvotetitlecell=new TableCell();
RadioButton mainvotetitleradio=new RadioButton();
mainvotetitleradio.Text=voterow["vote_text"].ToString();
mainvotetitleradio.ID="radio"+voterow["ID"].ToString();
mainvotetitleradio.GroupName="voteradio";
mainvotetitlecell.Controls.Add(mainvotetitleradio);
mainvotetitlecell.Font.Name="宋体";
mainvotetitlecell.Width=Unit.Percentage(30);
mainvotetitlecell.BorderWidth=2;
mainvoterow.Cells.Add(mainvotetitlecell);
if(voteid==1)
{
double wpercent;
wpercent=double.Parse(voterow["vote_number"].ToString())/total*100;
TableCell mainvoteshowcell=new TableCell();
mainvoteshowcell.Text="<img src='images/"+color.ToString()+".gif' border='0' width='"+wpercent.ToString("#.00")+"%' height='8'>"+voterow["vote_number"].ToString()+"票";
mainvoteshowcell.Font.Name="宋体";
mainvoteshowcell.Width=Unit.Percentage(60);
mainvoteshowcell.BorderWidth=2;
mainvoterow.Cells.Add(mainvoteshowcell);
TableCell mainvotecountcell=new TableCell();
mainvotecountcell.Text=wpercent.ToString("#.00")+"%";
mainvotecountcell.Font.Name="宋体";
mainvotecountcell.Width=Unit.Percentage(10);
mainvotecountcell.BorderWidth=2;
mainvotecountcell.HorizontalAlign=HorizontalAlign.Center;
mainvoterow.Cells.Add(mainvotecountcell);
}
else
{
TableCell mainvotenamecell=new TableCell();
string votepeople;
votepeople=voterow["vote_people"].ToString();
if(votepeople!="")
{
mainvotenamecell.Text=votepeople.Substring(1);
}
else
{
mainvotenamecell.Text=votepeople;
}
mainvotenamecell.Font.Name="宋体";
mainvotenamecell.Width=Unit.Percentage(70);
mainvotenamecell.BorderWidth=2;
mainvoterow.Cells.Add(mainvotenamecell);
}
mainvotetable.Rows.Add(mainvoterow);
color++;
if(color==5)
{color=0;}
}
TableRow mainvotebuttonrow=new TableRow();
TableCell mainvotebuttoncell=new TableCell();
Button mainvotebutton=new Button();
mainvotebutton.Text="投票";
mainvotebutton.Click+=new EventHandler(this.Vote);
mainvotebutton.ID="votebutton";
mainvotebuttoncell.Controls.Add(mainvotebutton);
mainvotebuttoncell.HorizontalAlign=HorizontalAlign.Center;
mainvotebuttoncell.ColumnSpan=voteid+2;
mainvotebuttonrow.Cells.Add(mainvotebuttoncell);
mainvotetable.Rows.Add(mainvotebuttonrow);
public void Vote(object o,EventArgs e)
{
int voteid=0;
db.Open();
OleDbDataReader pickvoteid=db.ExecuteReader("select vote_bbs,ID from [vote] where vote_bbs="+Int32.Parse(Session["replyid"].ToString()));
while(pickvoteid.Read())
{
RadioButton checkit=(RadioButton)(mainvotetable.FindControl("radio"+pickvoteid["ID"].ToString()));
if(checkit.Checked)
{
voteid=Int32.Parse(pickvoteid["ID"].ToString());
}
}
pickvoteid.Close();
db.Close();
}
其中有些是我自己写的类,你主要看RADIOBUTTON就可以了,呵呵,不好意思