Calendar in popup populating textbox

osmxx

New Member
I'm trying to incorporate a calendar into my forms for an application. I want to be able to have the date appear in a textbox and allow the user to click on a link next to the textbox that brings up a .net calendar in a separate window. The user then selects a date and the date is placed into the textbox using javascript. I found some code in an article on this site that is meant to do just that. And it works just fine on the site. However, even if I copy the code down via the supplied link and set up the input tag on the form page exactly the way it is outlined I'm still getting a javascript error after selecting the date on the calendar and it goes to populate the textbox on the main window.<BR><BR>Error:'window.opened.frmCalendar.txtDate' is null or not an object<BR><BR>Does anyone have any idea of what can cause this type of problem.<BR><BR>http://aspnet.4guysfromrolla.com/articles/030202-1.aspx?mode=print<BR><BR>http://aspnet.4guysfromrolla.com/articles/030202-1.2.aspx<BR><BR><BR>Any ideas would be appreciated.I discovered the solution to this one myself. The sample form was in an asp page and I was trying to use the same code in a aspx page. The difference is that you have to reference the ID part of the input tag or the asp:textbox tag if it is an aspx page rather than the name parameter for an asp page. For example, on the asp page the input tag would be:<BR><input type="text" name="txtDate"> <BR>and you would pass the 'txtDate' name to the calendar control page.<BR>On the aspx page the input tag would be:<BR><input type="text" id="txtDate"><BR>and you would pass the 'txtDate' name to the calendar control.<BR><BR>On the aspx page you can just as easily use the asp:textbox control and do the same thing:<BR><asp:textbox runat="server" id="txtDate" /><BR>In addition you can add any other validation controls you need to the same textbox.
 
Back
Top