Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

problem with request.querystring and date

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob - 09 Dec 2007 14:28 GMT
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] - 09 Dec 2007 14:53 GMT
> this gives the error: String was not recognized as a valid DateTime

What is the value of dat at this point...?

Signature

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

Bob - 09 Dec 2007 15:36 GMT
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?

>> this gives the error: String was not recognized as a valid DateTime
>
> What is the value of dat at this point...?
Peter Bucher [MVP] - 09 Dec 2007 15:49 GMT
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.

Signature

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

Peter Bucher [MVP] - 09 Dec 2007 15:30 GMT
Hello Bob

> 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/library/system.web.httputility.urldecode.aspx
-
http://msdn2.microsoft.com/en-us/library/system.web.httputility.urlencode.aspx

Signature

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] - 10 Dec 2007 23:56 GMT
Use Server.UrlEncode to encode the date before adding it to the querystring.
When you retrieve it from the querystring, use Server.UrlDecode.

Signature

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

> Hi,
>
[quoted text clipped - 14 lines]
> Thanks for help
> Bob

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.