sona
sona

Reputation: 175

How to disable future dates in WebDateChooser

I am using WebDateChooser in my .net application...by default the Date Chooser shows Current date,so that we can choose any date 10 years before the Current year and 10 years after the Current year...but i dont want to show the future date in the WebDateChooser. Is there any property to set the Maxdate as current date

<igsch:WebDateChooser ID="WebDateChooser1" runat="server">      
    </igsch:WebDateChooser><br />

Please help me if you have some idea

Upvotes: 0

Views: 2629

Answers (1)

Steve Dignan
Steve Dignan

Reputation: 8530

You can use the WebDateChooser.MaxDate Property.

In code (which I think suits your needs):

WebDateChooser1.MaxDate = DateTime.Now;

Or in the source (not dynamic so I just added for reference):

<igsch:WebDateChooser ID="WebDateChooser1" runat="server" MaxDate="2009-06-25">
</igsch:WebDateChooser>

UPDATE: (In response to the first comment from @sona)

Here's some code from my source file that accomplishes the setting of the MaxDate property dynamically.

<script runat="server">
void SetMaxDate(object sender , System.EventArgs e)
{
    WebDateChooser1.MaxDate = DateTime.Now;
}
</script>
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <igsch:WebDateChooser ID="WebDateChooser1" runat="server" OnInit="SetMaxDate">
        </igsch:WebDateChooser>

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

I can't attest to this being the best approach since my knowledge of asp.net is very limited. Although, it should work for you...

Upvotes: 3

Related Questions