Ver Mensaje Individual
  #10 (permalink)  
Antiguo 08/11/2004, 06:38
carlostapia
 
Fecha de Ingreso: septiembre-2004
Mensajes: 141
Antigüedad: 20 años, 5 meses
Puntos: 0
Cita:
Iniciado por luiscl
Hola!

Esto es lo que hago yo:

Pongo un html control image en el aspx que llama a una función de javascript

<IMG title="Pulse aquí para seleccionar la fecha del calendario" style="Z-INDEX: 132; LEFT: 320px; CURSOR: hand; POSITION: absolute; TOP: 352px"
onclick="GetDateTime('txtentrada')" alt="" src="calendar\icon-calendar.gif">

txtentrada es un textbox donde irá a para la fecha que he recuperado del pop-up que contiene el calendario.

Esta es la función javascript dentro del <head>, que llama a Calendar.aspx, que es el form que abre el calendario en un pop-up pequeñito:

<script language="javascript" type="text/javascript">
function GetDateTime(obj){
var url = 'Calendario.aspx?textbox=' + obj;
window.open(url,'cal','width=176,height=176,left=3 70,top=280,resizable=1,scrollbars=0');
}
</script>

El código para calendar.aspx (primero pongo el html, y luego el aspx)

<form id="Form1" method="post" runat="server">
<asp:calendar id="Calendar1" style="Z-INDEX: 101; LEFT: 0px; POSITION: absolute; TOP: 0px" runat="server"
BorderWidth="1px" BackColor="White" Width="176px" DayNameFormat="FirstLetter" ForeColor="#003399"
Height="176px" Font-Size="8pt" Font-Names="Verdana" BorderColor="#3366CC" CellPadding="1"
ShowGridLines="True">
<TodayDayStyle ForeColor="White" BackColor="#99CCCC"></TodayDayStyle>
<SelectorStyle ForeColor="#336666" BackColor="#99CCCC"></SelectorStyle>
<DayStyle BorderWidth="1px" BorderStyle="Groove"></DayStyle>
<NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF"></NextPrevStyle>
<DayHeaderStyle Height="1px" ForeColor="#336666" BackColor="#99CCCC"></DayHeaderStyle>
<SelectedDayStyle Font-Bold="True" ForeColor="#CCFF99" BackColor="#009999"></SelectedDayStyle>
<TitleStyle Font-Size="8pt" Font-Names="Verdana" Font-Bold="True" Height="25px" BorderWidth="1px"
ForeColor="#CCCCFF" BorderStyle="Solid" BorderColor="#3366CC" BackColor="#003399"></TitleStyle>
<WeekendDayStyle BackColor="#CCCCFF"></WeekendDayStyle>
<OtherMonthDayStyle ForeColor="#999999"></OtherMonthDayStyle>
</asp:calendar>
<asp:label id="Label1" style="Z-INDEX: 102; LEFT: 8px; POSITION: absolute; TOP: 184px" runat="server">Label</asp:label>
<INPUT id="Control" style="Z-INDEX: 103; LEFT: 8px; POSITION: absolute; TOP: 216px" type="hidden"
runat="server">
</form>


Y el code behind:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Control.Value = Request.QueryString("textbox").ToString()
End Sub

Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
Dim strScript As String = "<script>window.opener.document.forms(0)." + Control.Value + ".value = '"
strScript += Calendar1.SelectedDate.ToString()
strScript += "';self.close()"
strScript += "</" + "script>"
RegisterClientScriptBlock("ok", strScript)
Label1.Text = Control.Value
End Sub


Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
If (e.Day.Date.Day < Now.Day) Or (e.Day.Date.Month < Now.Month) Then
e.Day.IsSelectable = False
End If
End Sub

Espero que te sirva...cualquier duda, ya sabes dónde encontrarme



MEDIO EL SIGUIENTE ERROR

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30506: Handles clause requires a WithEvents variable.

Source Error:



Line 8: End Sub
Line 9:
Line 10: Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
Line 11: Dim strScript As String = "<script>window.opener.document.forms(0)." + Control.Value + ".value = '"
Line 12: strScript += Calendar1.SelectedDate.ToString()