Saturday

Controls.add c#/asp.net adding controls table/rows/labels

ASPX page must have placeholder

<asp:PlaceHolder ID="DynamicPlaceHolder" runat="server"></asp:PlaceHolder>


codebehind

protected override void OnPreRender(EventArgs e)
{
HtmlTable mainHtmlTable = new HtmlTable();
HtmlTableRow helpTableRow = AddLabelRow(mainHtmlTableRow.Cells.Count, "Hello World",true);
mainHtmlTable.Rows.Add(helpTableRow);
DynamicPlaceHolder.Controls.Add(mainHtmlTable);
}

public HtmlTableRow AddLabelRow(int cellCount, string text,bool applySkin)
{
HtmlTableRow helpTableRow = new HtmlTableRow();
HtmlTableCell helpTableCell = new HtmlTableCell();
//helpTableCell.Attributes.Add("style", "border: solid 2px; border-color: Blue;");
helpTableCell.ColSpan = cellCount;

Label helpLabel = new Label();
if (applySkin) helpLabel.SkinID = "labelBoldSkin";
helpLabel.Text = "<br>"+text;

helpTableCell.Controls.Add(helpLabel);
helpTableRow.Cells.Add(helpTableCell);
return helpTableRow;
}

more...

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...