problem with request.querystring and date

B

Bob

Hi,

i want to pass the date/time from one page to another page like this:

firts page:
---------
<asp:HyperLink ID="HyperLink1" NavigateUrl="mypage.aspx?dat= & 'date.now'"
runat="server">lijst</asp:HyperLink>

the code-behind of mypage.aspx
---------------------------------
Dim dd As Date
dd = Date.Parse(Request.QueryString("dat"))

this gives the error: String was not recognized as a valid DateTime

Thanks for help
Bob
 
B

Bob

Hi, thanks for replying.

When i go with he mouse over the link, i can read this:
mypage.aspx?dat=Date.Now
The problem is that i don't get the real date/time. I also tried without '
'.

I can solve this with code-behind like this:
Dim dat As Date
dat = Date.Now
HyperLink1.NavigateUrl = "mypage.aspx?dat=" & dat

This works, but i can't do that because in fact, the link is put into
Web.Sitemap file like this:
<siteMapNode url="mypage.aspx?dat='Date.Now'" title="mypage" description=""
/>

So i have to put everything in the URL, but how?
 
P

Peter Bucher [MVP]

Hello Bob
I can solve this with code-behind like this:
Dim dat As Date
dat = Date.Now
HyperLink1.NavigateUrl = "mypage.aspx?dat=" & dat
All Right.
I have testet that, and DataTime Values can submitted via GET without a En-
// Decoding.
Your problem ist, that you write the "Date.Time" as string literale, not as
code where executed.
This works, but i can't do that because in fact, the link is put into
Web.Sitemap file like this:
<siteMapNode url="mypage.aspx?dat='Date.Now'" title="mypage"
description=""
the web.sitemap file is only an xml file, there can not be dynamic code in
to be executed.
you can motifiy your sitemap file on runtime with code, so it would be
possible to
replace all "{DateTime.Now}" placeholders in the xml file with the real
value.

have a look to the msdn documentation over web.sitemap and the associated
classes.
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

Use Server.UrlEncode to encode the date before adding it to the querystring.
When you retrieve it from the querystring, use Server.UrlDecode.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top