views:

487

answers:

1

Hi,

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

+2  A: 

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...

Steve Dignan
Thanks Steve...it is working...do you know how to set the Current date as Maxdate in source?above you just typed the 2009-06-25. Is there any function to get the current date??I used Date() function but got error
sona
@sona, I updated my answer with some code that should address your comment.
Steve Dignan
yesthanks a lot Steve...
sona