Solved

Need help using dtPicker in an ASP page.

Posted on 2001-08-14
8
311 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
ID: 6386006
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
ID: 6386010
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
ID: 6388358
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 7

Accepted Solution

by:
John844 earned 50 total points
ID: 6388402
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
 
LVL 7

Expert Comment

by:John844
ID: 6388405
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
ID: 6388508
Thanks John. I appreciate your help.
0
 
LVL 7

Expert Comment

by:John844
ID: 6388577
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
ID: 6388891
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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