日期:2014-05-17 浏览次数:20494 次
<div style="height:100px; background-color: #C0C0C0;"> 测 试 </div> <asp:Panel ID="Panel1" runat="server" Height="443px" > </asp:Panel> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" style="height: 21px" />
private void addC() { Label labelFirstRear = new Label(); labelFirstRear.ID = "labelFirstRear"; labelFirstRear.Text = "测试" + " 你好大的单子"; labelFirstRear.Attributes.Add("style", "font-weight:bloder;font-size:18px;color:#ffffff;"); HtmlGenericControl brFirstRear = new HtmlGenericControl(); brFirstRear.TagName = "br"; HtmlGenericControl divFirstRear = new HtmlGenericControl(); divFirstRear.TagName = "div"; divFirstRear.ID = "我的div" ; divFirstRear.Attributes.Add("style", " background-color: red;"); divFirstRear.Controls.Add(labelFirstRear); divFirstRear.Controls.Add(divFirstRear); divFirstRear.Controls.Add(brFirstRear); labelFirstRear.Text = "这段内容已经结束"; divFirstRear.Controls.Add(labelFirstRear); divFirstRear.Controls.Add(brFirstRear); Panel1.Controls.Add(divFirstRear); }
<%@ Control Language="C#" ClassName="XXX" %> <%@ Import Namespace="System.Drawing" %> <%@ Implements Interface="IXXX" %> <script runat="server"> public override void DataBind() { base.DataBind(); DropDownList1.DataBind(); } public string Name { get { var nm = ViewState["name"]; return (string)nm ?? "无名氏"; } set { if (Name != value) { ViewState["name"] = value; EnsureChildControls(); pName.DataBind(); } } } public event Action NameChanged; public string MarkedValue { get { EnsureChildControls(); return this.DropDownList1.SelectedValue; } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { switch (this.DropDownList1.SelectedValue) { case "标记:红": this.div.ForeColor = Color.Red; break; case "标记:蓝": this.div.ForeColor = Color.Blue; break; case "标记:黑": this.div