Click to See Complete Forum and Search --> : Help with dynamic links


danrob79
01-11-2011, 08:00 PM
My workplace has an internal webpage that they want to update with dynamic links. The service allows for ASP/ASP.net.

The dynamic link would work as follows.

An employee would enter a date into a field. The date would need be inserted into the link in order to bring up a report for that particular day. For example, .../mainfolder/"selectedDate".pdf, where selected date is a variable obtained from the form field. On submit the employee would receive the normal dialog box asking them if they would like to open or save the file.

Can this be done. I am new to ASP and ASP.net, but willing to learn. If anyone could point me in the right direction I would be eternally grateful.

Thank you

yamaharuss
01-12-2011, 07:41 AM
This can be done easily.

FormPage.asp:

<%
myDate=Request.Form("MyDate")
If myDate <> "" then response.redirect "/mainfolder/"& myDate &".pdf"
%>
<form action="?">
Date: <input type="text" name="MyDate">
<input type="submit">
</form>

You may want to validate the date.. you could even use FSO to be sure the PDF file actually exists before redirecting to it but this will do what you asked.

yamaharuss
01-12-2011, 02:43 PM
forgot to add method=post to the form

danrob79
01-14-2011, 11:03 AM
Thank you for your help, it worked to perfection. To pick your brain some more if i wanted to add another form field (i.e. MyDept) and add this to the url, how would I do this?

example: /mainfolder/MyDeptMyDate.pdf

yamaharuss
01-14-2011, 11:58 AM
If your pdf was titled DeptDate.pdf then

<%
myDate=Request.Form("MyDate")
myDept=Request.Form("MyDept")
If myDate <> "" then response.redirect "/mainfolder/"& myDept &""& myDate &".pdf"
%>
<form action="?" method=post>
Date: <input type="text" name="MyDate">
Dept: <input type="text" name="MyDept">
<input type="submit">
</form>

Be sure you do some validation

danrob79
01-18-2011, 09:43 AM
Yamaharuss,

I got everything up and running yesteray. Your code was very helpful. Where do I send the flowers :)

yamaharuss
01-18-2011, 09:44 AM
Cool. Just help someone else whenever you get a chance.