did you add the control to the Controls collection? for example<form id="form1" runat="server">
...
<asp:PlaceHolder id="ph" runat="server" />
</form>ph.Controls.Add(call);

解决方案 »

  1.   

    Calendar cal1=new Calendar(); cal1.ID="cal1";
    cal1.Height=60;
    cal1.Width=160;
    cal1.ShowDayHeader=false;
    cal1.SelectedDate=DateTime.Now;
    cal1.SelectedDayStyle.BackColor=Color.Blue;
    this.PlaceHolder1.Controls.Add(cal1);
      

  2.   

    是的,下面还有几行添加到表格的代码: TableCell tc2 =new TableCell();
    tc2.Controls.Add(cal1);                           TableRow tr=new TableRow();
    tr.Cells.Add(tc2);

    Table1.Rows.Add(tr);运行时能正常显示出日历控件,点击时选中日期背景也能变成蓝色。但就是不能在初始显示时使所指定的日期背景为蓝。