Morpheusweb.it - Risorse per webmaster: script, ASP.NET, C#, Visual Basic .Net, tutorial, asp, javascript, css, php, html, java, ADO, VBScript, forms, frames, Active Server Pages, Dynamic HTML, database, gratis per webmaster e webdesigner

Calendario popup - << VERSIONE C# >>

Un calendario popup collegato ad una textbox


La pagina che apre il calendario

<%@ Page Language="vb" %>
<HTML>
<body>
<script>
function openCalendar()
{
  window.open('PopupCalendar.aspx?textbox=tbMyDate','cal','width=220,height=200,left=270,top=180')
}
</script>
<form id="Form1" method="post" runat="server">
<asp:textbox id="tbMyDate" runat="server" Width="80px"></asp:textbox>
<a href="javascript:openCalendar();"><img src="PopupCalendar.gif" border=0 ></a>
</form>
</body>
</HTML>


Il calendario popup

<%@ Page Language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<script runat="server">
Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As System.EventArgs)
  If Not Request.QueryString("textbox") Is Nothing Then
    Dim strScript As String = "<script>window.opener.document.forms(0)." & _
        Request.QueryString("textbox").ToString + ".value = '"
    strScript += CalPopup.SelectedDate.ToString("MM/dd/yyyy")
    strScript += "';self.close()"
    strScript += "</" + "script>"
    RegisterClientScriptBlock("Calendar_ChangeDate", strScript)
  End If
End Sub
</script>
<body style="margin:0px;">
<form id="Form1" runat="server">
<asp:Calendar id="CalPopup" OnSelectionChanged="Change_Date" runat="server" backcolor="#FFFFCC"
    width="220px" daynameformat="FirstLetter" forecolor="#663399" height="200px" font-size="8pt"
    font-names="Verdana" bordercolor="#FFCC66" BorderWidth="1px" ShowGridLines="True">
<TodayDayStyle ForeColor="White" BackColor="#FFCC66"></TodayDayStyle>
<SelectorStyle BackColor="#FFCC66"></SelectorStyle>
<NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC"></NextPrevStyle>
<DayHeaderStyle Height="1px" BackColor="#FFCC66"></DayHeaderStyle>
<SelectedDayStyle Font-Bold="True" BackColor="#CCCCFF"></SelectedDayStyle>
<TitleStyle Font-Size="9pt" Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></TitleStyle>
<OtherMonthDayStyle ForeColor="#CC9966"></OtherMonthDayStyle>
</asp:Calendar>
</form>
</body>
</HTML>


Scarica il Codice...


Stampa la pagina


 


Inizio pagina

risorse per webmaster