by
Neon Quach
30. July 2010 16:03
Thay vì cho phép user nhận ngày tháng năm sinh chẳng hạn bằng input control thông thường, cải tiến hơn người ta thường dùng calendar hổ trợ người dùng chỉ chọn ngày tháng thay vì phải nhập, và giúp chúng ta có thể hạn chế vấn đề lổi nhập liệu của người dùng.
Bạn có thể tạo 1 calendar dể dàng với thư viện jquery ui version 1.8.2 có thể tải tại đây
Với 1 vài thao tác đơn giản chúng ta có ngay 1 calendar
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="lib/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="lib/jquery.ui.datepicker.js" type="text/javascript"></script>
<script src="lib/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script>
<link href="lib/jquery-ui-1.8.2.custom.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
$(function () {
$("#txtCalendar").datepicker({ changeYear: true, yearRange: '1950:2010' });
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtCalendar" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
Hope this help