This is small demonstration of a C# program to get selected date of a calendar using C#.
Calendar expose a method to get the selected date. there is other more methods, you can go though them one by one.
cldTest.SelectedDate.ToShortDateString()
Program Code:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void cldTest_SelectionChanged(object sender, EventArgs e)
{
Response.Write("Your Date Selection is: " + cldTest.SelectedDate.ToShortDateString() + "<br>");
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Calendar ID="cldTest" runat="server" OnSelectionChanged="cldTest_SelectionChanged"></asp:Calendar>
</div>
</form>
</body>
</html>
No comments:
Post a Comment