Home > Javascript > Popup Calender with Javascript

Popup Calender with Javascript

Try this example:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Popup.aspx.cs" Inherits="NewFolder1_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>">

<html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
    <asp:Calendar ID="calDate" OnSelectionChanged="Change_Date" Runat="server" />
    <input type="hidden" id="control" runat="server" />



using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class NewFolder1_Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        control.Value = Request.QueryString["textbox"].ToString();
    protected void Change_Date(object sender, EventArgs e)
        string strScript  = "<script>window.opener.document.forms(0)." + control.Value + ".value = '";
        strScript += calDate.SelectedDate.ToString("dd/MM/yyyy");
        //strScript += calDate.SelectedDate.ToString("MM/dd/yyyy");
        strScript += "';self.close()";
        strScript += "</" + "script>";


<asp:TextBox ID="txtEndDate" Runat="server" />

<a href="javascript:;" onclick="window.open('Popup.aspx?textbox=<%=txtEndDate.ClientID%>','cal','width=300,height=300,left=300,top=300')">
      <img src="images/Calendar_scheduleHS.png" border="0" title="Select End Date"></a>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Select End Date" ControlToValidate="txtEndDate"></asp:RequiredFieldValidator>


Good Luck

Categories: Javascript
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: