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
215
Adding WebDateChooser to the a page from code behind
posted

I am trying to add a WebDateChooser to my .aspx page from code behind. When the page is run the control renders but when you click on the drop down image to view the calender nothing happens. What an i doing wrong?

 

Here is my code.

 

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Infragistics.WebUI.WebSchedule.WebDateChooser wdc = new Infragistics.WebUI.WebSchedule.WebDateChooser();
            wdc.ID = "tempID";
            wdc.Width = Unit.Pixel(75);

            Page.Controls.Add(wdc);
        }
    }
}

 

 

and the markup

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>

<%@ Register assembly="Infragistics2.WebUI.WebDateChooser.v7.3, Version=7.3.20073.38, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.WebUI.WebSchedule" tagprefix="igsch" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
</html>

 

Any help is much appreciated.

 

Thanks

  • 24497
    posted

    Hi mhussain,

    The dot-net does not support server controls outside of <form>. You should use form instead of page.
    Examples to fix:

    this.Form.Controls.Add(wdc);
    or
    this.Page.Form.Controls.Add(wdc);
    or
    this.form1.Controls.Add(wdc);