Calendar

In questo esempio abbiamo un file .aspx che definisce il calendario ed un altro file .aspx che lo richiama. Il link Seleziona data richiama lo scipt popdata  che richiama il file asp. che apre il calendario. La seleziona della data riporta il dato nel campo testo del file test.aspx.

 

Calendar.aspx

 

 <SCRIPT runat="server">
   Sub ShowDate(sender As Object, e As EventArgs)
      Response.Write ("<SCRIPT language=""Javascript""><!--" & VbCrlf)
      Response.write ("window.opener." & Request("campo") & ".value='")
      Response.Write(cal.SelectedDate.ToString("dd/MM/yyyy") & "';" & vbCrLf)
      Response.Write ("self.close();" & VbCrLf)
      Response.Write ("--></SCRIP")
      Response.Write ("T>")
   End sub
</SCRIPT>
<html>
   <head><title>Seleziona una data</title></head>
   <body>
   <SCRIPT language="Javascript">
      this.focus();
   </SCRIPT>
   <form runat="server" id="form1">
      <asp:Calendar id="cal" runat="server" enableviewstate="false"
            onselectionchanged="ShowDate" Font-Name="Arial" Font-Size="12px"
            TodayDayStyle-BackColor="red" DayHeaderStyle-BackColor="lightsteelblue"
            OtherMonthDayStyle-ForeColor="gray" NextPrevStyle-ForeColor="white"
            TitleStyle-BackColor="gray" TitleStyle-ForeColor="white"
            TitleStyle-Font-Bold="True" TitleStyle-Font-Size="15px"
            SelectedDayStyle-BackColor="Navy" SelectedDayStyle-Font-Bold="True"/>
      </form>
   </body>
</html>

 

test.aspx

 

<form method="post" id="frm" runat="server">
   <table border=0 cellspacing=2 cellpadding=3 bgcolor="lightsteelblue" width=100%>
      <tr>
         <td>Data (GG/MM/YY)</td>
         <td><input class="tbflat" size=13 type="text" name="data">
             <a href="javascript:popdate('frm.data', '');">Seleziona data</a>
         </td>
      </tr>
      <tr>
         <td></td>
         <td><input type="submit" value=" Salva ""></td>
      </tr>
   </table>
</form>
<SCRIPT Language="JavaScript"><!--
   function popdate(campo, valore) {
      CalWin = window.open('calendar.aspx?campo='+campo+'&data='+valore,
               'calwindow','width=200,height=180,scrollbars=no,toolbar=no')
   }
//--></SCRIPT>