The purpose of this control is show up a calendar where the user can pick a date, all the jquery libreries needed has been directly referenced from the Google CDN.
We can get and set the value of the control through the text property of the control and also we can change the calendar culture as we can see in the line datepicker($.datepicker.regional[‘es’]).
El propósito de este control es mostrar un calendario donde el usuario puede elegir una fecha, todas las librerías jQuery necesarias se referencian desde el CDN de Google.
Podemos obtener y establecer el valor del control a través de la propiedad de text del control y también podemos cambiar la cultura de calendario como podemos ver en la línea datepicker($.datepicker.regional[‘es’]).
The Control:
<%@ Control Language=»C#» AutoEventWireup=»true» CodeFile=»Calendar.ascx.cs» Inherits=»Calendar» %>
<link href=»http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-lightness/jquery-ui.css» rel=»stylesheet» type=»text/css» />
<script src=»http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js»
type=»text/javascript»></script>
<script src=»http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js»
type=»text/javascript»></script>
<script src=»http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/i18n/jquery-ui-i18n.min.js»
type=»text/javascript»></script>
<script type=»text/javascript»>
$(function() {
$.datepicker.setDefaults($.datepicker.regional[»]);
$(«#<%=datepicker1.ClientID %>»).datepicker($.datepicker.regional[‘es’]);
});
</script>
<div>
<asp:Label ID=»lblFecha» runat=»server» Text=»Fecha: «></asp:Label>
<asp:TextBox ID=»datepicker1″ runat=»server»></asp:TextBox>
</div>
Code Behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Calendar : System.Web.UI.UserControl
{
public string text
{
get { return datepicker1.Text ; }
set { datepicker1.Text = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
The Page :
<%@ Page Language=»C#» AutoEventWireup=»true» CodeFile=»Default.aspx.cs» Inherits=»_Default»%>
<%@ Register src=»calendar.ascx» tagname=»calendar» tagprefix=»uc3″ %>
<!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»>
</head>
<body>
<form id=»form1″ runat=»server»>
<asp:ScriptManager ID=»sp1″ runat =»server»>
</asp:ScriptManager>
<div>
<uc3:calendar ID =»calendar1″ runat =»server» />
</div>
</form>
</body>
</html>
You can download the code from here/ Puedes descargar el codigo desde aqui.