• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

Need help using dtPicker in an ASP page.

I have an ASP page (using VBScript) and need to use the dtPicker to allow data entry of a date. Including the following <object> on a form displays the control correctly but I do not know how to reference the date in the ASP page.

<object ID="Microsoft Date and Time Picker Control 6.0 (SP4)" classid="CLSID:20DD1B9E-87C4-11D1-8BE3-0000F8754DA1" width=120 height=25>
</object>

0
BryanC
Asked:
BryanC
  • 4
  • 3
1 Solution
 
mattykCommented:
Place the object inside of the form you are going to be using.  I would then remove the ID attribute all together and add a name attribute set to something simple.  Like this:

<form action="junk.asp">
<object name="datePicker" classid="CLSID:20DD1B9E-87C4-11D1-8BE3-0000F8754DA1"
width=120 height=25>
</object>
<input type=submit>
</form>

than in the asp that is going to be processing things you can simply use

request.querystring("datePicker")


Here's a sample working page.  Save this page as junk.asp and run it:

<body>
<form action="junk.asp">

<object name="datePicker" classid="CLSID:20DD1B9E-87C4-11D1-8BE3-0000F8754DA1"
width=120 height=25>
</object>

<input type=submit>
</form>

<hr>
<%
for each key in request.querystring
     response.write key & " = " & request.querystring(key) & "<br>"
next
%>
</body>

cheers,
matty
0
 
John844Commented:
start by changing the id to something usable in script like
<object ID="test" classid="CLSID:20DD1B9E-87C4-11D1-8BE3-0000F8754DA1"
width=120 height=25>
</object>


you can then trap for changes in the control like

<SCRIPT LANGUAGE=javascript FOR=test EVENT=Change>
<!--
     alert(test.Year)
//-->
</SCRIPT>

if you want to get to the values in asp after the user picks a value then you will need a form to submit the information back to the server.  Add a hidden field and call it txtTest for now.  Here is the code to update the hidden field to the date entered.

<SCRIPT LANGUAGE=javascript FOR=test EVENT=Change>
<!--
     document.forms(0).item("txtTest").value = test.Month + "/" + test.Day + "/" + test.Year
//-->
</SCRIPT>
0
 
BryanCAuthor Commented:
Thanks Matty and John. You did help me solve my original problem but now I have a problem initializing the value of the control. In the following code the FORMAT is set correctly but the VALUE is not. Does anyone know what I am doing wrong?

<%
strURL       = Request.ServerVariables("URL")
ReportDate   = Request.Form("DatePicker")
%>
<form action="<%= strURL %>" method="post">
     Select Starting Date:
     <object name="datePicker" classid="CLSID:20DD1B9E-87C4-11D1-8BE3-0000F8754DA1" width=150 height=25>
     <PARAM name="FORMAT" value="1" >
     <PARAM name="VALUE" value=<%=ReportDate%> >
     </object>
     <br>
     <input type="submit" Name="GenReportBtn" Value="Generate Report" />
</form>
<%
response.write("ReportDate   = " & ReportDate & "<br>")
%>


0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
John844Commented:
try this, change
<PARAM name="VALUE" value=<%=ReportDate%> >
to
<PARAM NAME="CurrentDate" VALUE="<%=cdbl(cdate(ReportDate))%>">

the current date parameter is expecting the numeric representation of the date.
0
 
John844Commented:
you might try just adding "s around the value like
<PARAM name="VALUE" value="<%=ReportDate%>" >

I haven't tried this to verify it.
0
 
BryanCAuthor Commented:
Thanks John. I appreciate your help.
0
 
John844Commented:
No problem, I enjoy it.  If this question is complete, you should accept one of the answers provided so that points are awarded and this question will be moved into the Previously Asked Question collection.

John
0
 
BryanCAuthor Commented:
This was my first time to use the devX system and I am very pleased. I thank you again for the help.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now