problem with date conversion

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
 
H

Herfried K. Wagner [MVP]

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

firts page:

I am not familiar with ASP.NET, but I wonder if the value of the
'NavigateUrl' attribute really contains the date using the syntax used
above. In addition, make sure you use 'CultureInfo.InvariantCulture' in
'Now.ToString(...)' to use a culture-invariant date format.
 
A

Andrew Morton

Bob said:
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

I suspect your date is getting slashes in it, which in a URL may mess things
up. Try DateTime.Now.ToString("yyyyMMddTHHmmss").

Andrew
 
H

Hal Rosser

Bob said:
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

Why dont you try using a session variable. It lives with the user's session.
 

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

Top