Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to restrict user not to select previous years using Textbox calendar extender.
---------------------------------------------------------------------------------

Hi FRNDS,

my project is based on Asp.net c#.

In this Project, We will create new users to access the Project.

In this we have a form with ADD NEW USER.... in this we should enter all user details.
and by the way we have Issue Date and Expiry Date for access.

Issue date will be the System date itself. and for Expiry date he should choose from TextBox calendar extender.

So my requirement is Calendar Extender has Previous years and Further years.

Only he should choose further years. if he choose previous years, a message should be displayed.


Please help me THANKS.
Posted

1 solution

go trough following links Tip.6..
AJAX Calender Extender[^]

ASP.NET
<head runat="server">
    <title>Calendar Extender</title>
    <script type="text/javascript">
    function checkDate(sender,args)
{
var selDate= sender._selectedDate;
var today = new Date();
 if (selDate.getFullYear() > today.getFullYear())
{
alert("You cannot select a day earlier than today!");
sender._selectedDate = new Date();
// set the date back to the current date
sender._textbox.set_Value(sender._selectedDate.format(sender._format))
}
}
    </script>
</head>

 

<form id="form1" runat="server">
    <asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown" />
    <div>
        <asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown"></asp:textbox>
        <cc1:calendarextender id="CalendarExtender1" xmlns:cc1="#unknown">
        runat="server" OnClientDateSelectionChanged="checkDate" TargetControlID="TextBox1" />
    </cc1:calendarextender></div>
</form>


..try something like this..also search for "textbox calendar extender with range validator" on google...
...same thing discussed over here

http://forums.asp.net/t/1167739.aspx/1[^][^]
 
Share this answer
 
Comments
Software Engineer 892 10-Feb-13 7:01am    
Many Thanks PALLAVI Garu.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900