Now
let us create the one sample application to do our task as:
- 1. "Start" - "All Programs" - "Microsoft Visual Studio 2010".
- "File" - "New web Site" - "C#" - "Empty Website" (to avoid adding a master page).
- Provide the web site a name such as Ajax Calendar or another as you wish and specify the location.
- Then right-click on Solution Explorer - "Add New Item" - "Default.aspx" page.
- Drag and drop one textbox and one Script Manager from Ajax Extension section on the <form> section of the Default.aspx page.
disable
past dates in ajax calendar extender
Now the source code of the Default.aspx should
look as in the following:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DissableDates.aspx.cs" Inherits="DissableDates" %>
<%@
Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
TagPrefix="asp"
%>
<!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">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<center>
<h3>
Dissable past Dates in Ajax
calender
</h3>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="Calendar1" runat="server" TargetControlID="TextBox1" Format="dd/MM/yyyy">
</asp:CalendarExtender>
</center>
</div>
</form>
</body>
</html>
Now
use the following code in the .cs file.
using System;
public partial class DissableDates : System.Web.UI.Page
{
protected void Page_Load(object
sender, EventArgs e)
{
Calendar1.StartDate = DateTime.Now;
}
}
Output
disable
future dates in ajax calendar extender
Now the source code of the Default.aspx should
look as in the following:
<%@ Page
Language="C#"
AutoEventWireup="true"
CodeFile="Dissable
futur Dates.aspx.cs" Inherits="Dissable_futur_Dates" %>
<%@ Register
Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit"
TagPrefix="asp"
%>
<!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">
<asp:ScriptManager ID="ScriptManager1"
runat="server">
</asp:ScriptManager>
<div>
<center>
<h3>
Dissable futur Dates in Ajax calender
</h3>
<br />
<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
<asp:CalendarExtender ID="Calendar1"
runat="server"
TargetControlID="TextBox1"
Format="dd/MM/yyyy">
</asp:CalendarExtender>
</center>
</div>
</form>
</body>
</html>
Now
use the following code in the .cs file.
using System;
public partial class Dissable_futur_Dates
: System.Web.UI.Page
{
protected void
Page_Load(object sender, EventArgs e)
{
Calendar1.EndDate = DateTime.Now;
}
}
Output
No comments:
Post a Comment