popup calendar

liunx

Guest
hi someone plz help im trying to create a popup calendar using asp.net and c#
ive created a popup window with a calendar in javascript but heres the catch how do get the selected date back to a textbox in the previous window
someone plz help
Aiysha
Thanks in advanceHere's how I do it...

Create a webpage with JUST the calendar control on it.

On this page, use the following code...


Private Sub calCalendar_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles calCalendar.SelectionChanged
If Not Request.QueryString("textbox") Is Nothing Then
Dim strScript As String = "<script>window.opener.document.forms(0)." + Request.QueryString("textbox").ToString + ".value = '"
strScript += calCalendar.SelectedDate.ToString("dd/MM/yyyy")
strScript += "';self.close()"
strScript += "</" + "script>"
RegisterClientScriptBlock("Calendar_ChangeDate", strScript)
End If
End Sub


Then, on the page that's going to call the calendar use the following...

Create an IMG


<IMG language="javascript" class="imageButton" id="imgDate" onclick="return imgDate_onclick()" alt="" src=http://www.webdeveloper.com/forum/archive/index.php/"Images/24x24/calendar.png" align="absMiddle" border="0">


And then have the following JavaScript...


function imgDate_onclick() {
window.open('calendar.aspx?textbox=txtDate','','width=320,height=220,left=270,top=180');
}


What you need to know is that the Javascript contains a call to the calendar.aspx webpage, the querystring needs to reference the control that's going to hold the returned date.

So in my example, I've a textbox called "txtDate" which is the control that will hold the returned value.

Hope that helps.Thanks for ur help but i already figured that prob out
 
Back
Top