Solved

Need help using dtPicker in an ASP page.

Posted on 2001-08-14
8
315 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Html Table Looping (part 2) 5 41
Executing a script on a timer online 5 43
IIS 7 and executing pages using localhost 16 31
JS to redirect to prev page 8 45
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

737 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