Introduction
This is Vivek's Popup Calendar using ASP.NET, Jscript and C#. The popup calendar I have developed using Microsoft technology is more simple to use and easy to integrate with your .NET web application. Software requirements to run this program:
- .NET Framework
- IIS Web Server
- Internet Explorer
How to run this program:
- First, create a virtual directory in your web server for this program with your desired name.
- Include all the files in the folder PopUpByVivek into your virtual directory.
- Next right click on the file TestSreen.aspx and click browse.
Important Code Parts of the Application
C# Code
private void CalVivek_SelectionChanged(object sender, System.EventArgs e)
{
if (Request.QueryString["textbox"] != "")
{
string strScript = "<SCRIPT>window.opener.document.forms(0)." +
Request.QueryString["textbox"].ToString() + ".value = '";
strScript += CalVivek.SelectedDate.ToString("MM/dd/yyyy");
strScript += "';self.close()";
strScript += "</" + "script>";
RegisterClientScriptBlock("Calendar_ChangeDate", strScript);
}
}
Jscript Code
var popUp;
function OpenCalendar(idname, postBack)
{
popUp = window.open('Calendar.aspx?formname=' +
document.forms[0].name +
'&id=' + idname + '&selected=' +
document.forms[0].elements[idname].value +
'&postBack=' + postBack, 'popupcal',
'width=165,height=208,left=200,top=250');
}
function SetDate(formName, id, newDate, postBack)
{
eval('var theform = document.' + formName + ';');
popUp.close();
theform.elements[id].value = newDate;
if (postBack) __doPostBack(id,'');
}