Connecting Tech Pros Worldwide Help | Site Map

problem with request.querystring and date

Bob
Guest
 
Posts: n/a
#1: Dec 9 '07
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



Mark Rae [MVP]
Guest
 
Posts: n/a
#2: Dec 9 '07

re: problem with request.querystring and date


"Bob" <cq@qs.qdqdwrote in message
news:uH1DI$mOIHA.4880@TK2MSFTNGP03.phx.gbl...
Quote:
this gives the error: String was not recognized as a valid DateTime
What is the value of dat at this point...?


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Peter Bucher [MVP]
Guest
 
Posts: n/a
#3: Dec 9 '07

re: problem with request.querystring and date


Hello Bob
Quote:
i want to pass the date/time from one page to another page like this:
[...]
this gives the error: String was not recognized as a valid DateTime
Use UrlDecode and UrlEncode.
-
http://msdn2.microsoft.com/en-us/lib...urldecode.aspx
-
http://msdn2.microsoft.com/en-us/lib...urlencode.aspx

--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
Guest
 
Posts: n/a
#4: Dec 11 '07

re: problem with request.querystring and date


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

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net


"Bob" <cq@qs.qdqdwrote in message
news:uH1DI$mOIHA.4880@TK2MSFTNGP03.phx.gbl...
Quote:
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
>
>
>
Closed Thread