Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pop-up calendar 2

Status
Not open for further replies.

mariacri11

Programmer
Apr 9, 2003
22
0
0
CY

I want to extract a selected date from a calendar and not to display it on my window permanently.
I tried to create a calendar object in the moment that I press a button but the calendar doesn't seem to apear.
Still, it exists, as I can display the selected date.

I thought maby someone was confrunted with the same problem as I did, and whants to help me!

Thank You!

Maria
 
This method pop up a window with a calendar control in it.

1)Here is the textbox that I want to fill and the link to open the pop up window
<asp:TextBox id=&quot;txtDateDue&quot; tabIndex=&quot;11&quot; runat=&quot;server&quot;></asp:TextBox>
<A href=&quot;javascript:_DatePickerOpener('Form1','txtDateDue');&quot;>
<IMG style=&quot;WIDTH: 22px; HEIGHT: 17px&quot; height=&quot;17&quot; src=&quot;images\calendar.jpg&quot; width=&quot;22&quot; border=&quot;0&quot;></A>

2) Here is the javascript to open the window:
<script language=&quot;javascript&quot;>
function _DatePickerOpener(varfn,vartn)
{
var OpenCal;
OpenCal=&quot;CalControl.aspx?fn=&quot;+varfn+&quot;&tn=&quot;+vartn
window.open (OpenCal,&quot;Noname&quot;, 'scrollbars=yes,status=no,width=275,height=220,resizable=yes,top=0')
}
</script>

3) Here is the calander.aspx
<%@ Page Language=&quot;vb&quot; AutoEventWireup=&quot;false&quot; Codebehind=&quot;CalControl.aspx.vb&quot; Inherits=&quot;Web.CalControl&quot; %>
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
</HEAD>
<body onload=&quot;CalScript();&quot;>
<form runat=&quot;server&quot; ID=&quot;Form1&quot;>
<asp:Calendar id=&quot;Calendar1&quot; runat=&quot;server&quot; Font-Name=&quot;Verdana;Arial&quot; Font-Size=&quot;9pt&quot; Height=&quot;178px&quot; Width=&quot;235px&quot; TodayDayStyle-Font-Bold=&quot;True&quot; DayHeaderStyle-Font-Bold=&quot;True&quot; BorderStyle=&quot;Solid&quot; NextPrevFormat=&quot;ShortMonth&quot; BackColor=&quot;White&quot; ForeColor=&quot;Black&quot; CellSpacing=&quot;1&quot; Font-Names=&quot;Verdana&quot; BorderColor=&quot;Black&quot;>
<TodayDayStyle ForeColor=&quot;White&quot; BackColor=&quot;#999999&quot;></TodayDayStyle>
<DayStyle BackColor=&quot;#CCCCCC&quot;></DayStyle>
<NextPrevStyle Font-Size=&quot;8pt&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot;></NextPrevStyle>
<DayHeaderStyle Font-Size=&quot;8pt&quot; Font-Bold=&quot;True&quot; Height=&quot;8pt&quot; ForeColor=&quot;#333333&quot;></DayHeaderStyle>
<SelectedDayStyle ForeColor=&quot;White&quot; BackColor=&quot;#333399&quot;></SelectedDayStyle>
<TitleStyle Font-Size=&quot;12pt&quot; Font-Bold=&quot;True&quot; Height=&quot;12pt&quot; ForeColor=&quot;White&quot; BackColor=&quot;#333399&quot;></TitleStyle>
<OtherMonthDayStyle ForeColor=&quot;#999999&quot;></OtherMonthDayStyle>
</asp:Calendar>
<INPUT id=&quot;txtDate&quot; runat=&quot;server&quot; type=&quot;hidden&quot;>
</form>
<script language=&quot;javascript&quot;>
function CalScript()
{
if (!(Form1.txtDate.value==&quot;&quot;))
{
window.opener.<%=Request(&quot;fn&quot;)%>.<%=Request(&quot;tn&quot;)%>.value=Form1.txtDate.value
window.close()
}
}
</script>
</body>
</HTML>

Public Class CalControl
Inherits System.Web.UI.Page
Protected WithEvents txtDate As System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar

#Region &quot; Web Form Designer Generated Code &quot;

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
If Calendar1.SelectedDates.Count = 1 Then
txtDate.Value = Calendar1.SelectedDate.ToShortDateString
End If
End Sub


End Class



Good Luck

 
hello - when i used the code above, the calendar appears on the webform permanently instead of in a pop up window...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top