日期:2014-05-18 浏览次数:20479 次
protected override void Render(HtmlTextWriter writer) { //tb是自定义控件中的一个TextBox //lb是自定义控件中的一个Label //rev是一个验证控件 Table table=new Table(); table.CellPadding = 0; table.CellSpacing = 0; table.BorderWidth = 0; TableRow tableRow=new TableRow(); TableCell tableCell1=new TableCell(); tableCell1.Controls.Add(lb); tableRow.Controls.Add(tableCell1); TableCell tableCell2 = new TableCell(); tableCell2.Controls.Add(tb); tableRow.Controls.Add(tableCell2); TableCell tableCell3 = new TableCell(); tableCell2.Controls.Add(rev); tableRow.Controls.Add(tableCell3); table.Rows.Add(tableRow); table.RenderControl(writer); }
protected override void Render(HtmlTextWriter writer) { //tb是自定义控件中的一个TextBox //lb是自定义控件中的一个Label //rev是一个验证控件 writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.RenderBeginTag(HtmlTextWriterTag.Td); this.lb.RenderControl(writer); writer.RenderEndTag(); writer.RenderBeginTag(HtmlTextWriterTag.Td); this.tb.RenderControl(writer); writer.RenderEndTag(); if(!string.IsNullOrEmpty(this.ValidateExpression)&&!this.DesignMode) { writer.RenderBeginTag(HtmlTextWriterTag.Td); this.rev.RenderControl(writer); writer.RenderEndTag(); } writer.RenderEndTag(); writer.RenderEndTag(); }