Solved

Need help using dtPicker in an ASP page.

Posted on 2001-08-14
8
301 Views
Last Modified: 2007-12-19
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
Comment
Question by:BryanC
  • 4
  • 3
8 Comments
 
LVL 5

Expert Comment

by:mattyk
Comment Utility
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
 
LVL 7

Expert Comment

by:John844
Comment Utility
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
 

Author Comment

by:BryanC
Comment Utility
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
 
LVL 7

Accepted Solution

by:
John844 earned 50 total points
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 7

Expert Comment

by:John844
Comment Utility
you might try just adding "s around the value like
<PARAM name="VALUE" value="<%=ReportDate%>" >

I haven't tried this to verify it.
0
 

Author Comment

by:BryanC
Comment Utility
Thanks John. I appreciate your help.
0
 
LVL 7

Expert Comment

by:John844
Comment Utility
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
 

Author Comment

by:BryanC
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now