problem with request.querystring and date

  • Thread starter Thread starter Bob
  • Start date Start 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
 
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?
 
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.
 
Use Server.UrlEncode to encode the date before adding it to the querystring.
When you retrieve it from the querystring, use Server.UrlDecode.
 
Back
Top