I was making a yearly calendar and i needed to output the cells to represent the days in the year. At first i just made a public variable, filled it up with html and then outputed it to the page like this:-

1
<%=variablename%>

This seemed to work well but the page didn’t update on postback methods because the html was being rendered before any methods were executing.
I figured there must be a way to output to the current page so i had a look around and found some code that updated a panel control. To send it raw html use this command:-

1
panMainCalendar.Controls.Add(new LiteralControl("<tr><td height='20'><div align='left'>"));

To add a control try this:-

1
2
3
4
5
6
7
8
Button NLab = new Button();
Unit NU = new Unit(100,UnitType.Percentage);
NLab.Width = NU;
NLab.Height = NU;
NLab.Click += Day_Click;
NLab.CssClass = "ButtonCell";
NLab.ID = "lbCell_"+Day + "_" + Month + "_" + Year;
panMainCalendar.Controls.Add(NLab);

Good Luck