Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Render Web Date Chooser
posted

I have a Table object in code behind which i want to build and render.

Inside this Table i have two columns that need a Date Picker.

My code looks something like:

 

WebDateChooser wdcStart = new WebDateChooser();
wdcStart.Value = Convert.ToDateTime(item.StartDate);
wdcStart.Height = 19;
wdcStart.MinDate = Convert.ToDateTime("1900-01-01");
wdcStart.MaxDate = Convert.ToDateTime("2030-12-31");
wdcStart.Font.Names = new string[] { "Verdana" };
wdcStart.Font.Size = FontUnit.Point(8);
 
PlaceHolder phStart = new PlaceHolder();
phStart.Controls.Add(wdcStart);
TableCell tcStartDate = new TableCell();
tcStartDate.Controls.Add(phStart);

 

The control isn't rendering quite correctly, it displays 
the correct item.StartDate but it does not show me the
down arrow that a normal WebDateChooser would 
display and on click it does not drop down the calendar.
Please, is there any way to fix this?
I need to render the table from code behind so changing 
this is not a solution, and i would prefer to use a normal 
Table object instead of UltraWebGrid as the overall 
performance is somewhat better.
Thank you.


 

  • 24497
    posted

    Hi Giorgios,

    I added an empty webform to a website, and css implemented by following. It worked ok and I did not find problems. It is possible that if your application uses some special layout or css classes with unexpected attributes, then that may affect appearance and behavior of date chooser. You may try to debug/analize that by building a temporary debug webform and step by step reduce functionality and content. It may allow you to find reason for misbehavior.

    protected void Page_Load(object sender, EventArgs e)
    {
      WebDateChooser wdcStart = new WebDateChooser();
      //wdcStart.Value = Convert.ToDateTime(item.StartDate);
      wdcStart.Height = 19;
      wdcStart.MinDate = Convert.ToDateTime("1900-01-01");
      wdcStart.MaxDate = Convert.ToDateTime("2030-12-31");
      wdcStart.Font.Names = new string[] { "Verdana" };
      wdcStart.Font.Size = FontUnit.Point(8);

      Table t = new Table();
      TableRow row = new TableRow();
      this.Form.Controls.Add(t);
      PlaceHolder phStart = new PlaceHolder();
      phStart.Controls.Add(wdcStart);
      TableCell tcStartDate = new TableCell();
      tcStartDate.Controls.Add(phStart);
      row.Cells.Add(tcStartDate);
      PlaceHolder phStart2 = new PlaceHolder();
      phStart2.Controls.Add(new WebDateChooser());
      TableCell tcStartDate2 = new TableCell();
      tcStartDate2.Controls.Add(phStart2);
      row.Cells.Add(tcStartDate2);
      t.Rows.Add(row);
    }