Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Date string problem in query string when posting back

Reply
Thread Tools

Date string problem in query string when posting back

 
 
=?Utf-8?B?SnVsaWEgQg==?=
Guest
Posts: n/a
 
      08-29-2007
Hi,

I posted last week about a problem I've got and didn't get any responses,
but I've managed to come up with a workaround and a possible cause
(guessing). I was wondering if someone could confirm my theories and give me
some information on the proper way to handle this.

I have a search results web page that is opened with info in the query
string. It's handled fine by asp.net, but when the user navigates away from
the page then goes back to it, the query string does not return the expected
results e.g.

http://localhost/GSContracts/SearchR...ateTo=29/08/07

When going to the page first time, the query string returns values as seen,
but when going back to the page dateFrom returns "" and dateTo returns
Nothing.

I've guessed that it's something to do with the fact that a post back is
processed through javascript and javascript may not recognise the /
character?? Like I said, total guesswork... so I've used some shared global
variables in my application to get around this problem.

This works fine, but I'm sure there's a more elegant solution? Perhaps, if
I'm right, there's a format I should be using for dates in query strings, so
javascript can process it?

Thanks in advance.
 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      08-29-2007
What if you check the raw url ? It would first allow to check if query
string parameters are totally cleared or if they are still there but have
some problem for reading them...
The method you are using to "return back" to this page (this is nothing else
than a postback ?) may also help.

Also the culprit could perhaps be the / character. Is 00/00/00 expected ? It
looks a bit weird for a date ?

Let us know if you are still stuck so that we can try a repro if needed (I
don't remember to have noticed this but I generally pass only numbers).

---
Patrice

"Julia B" <> a écrit dans le message de
news: C9CCA1D8-C8F7-4A85-8B3A-...
> Hi,
>
> I posted last week about a problem I've got and didn't get any responses,
> but I've managed to come up with a workaround and a possible cause
> (guessing). I was wondering if someone could confirm my theories and give
> me
> some information on the proper way to handle this.
>
> I have a search results web page that is opened with info in the query
> string. It's handled fine by asp.net, but when the user navigates away
> from
> the page then goes back to it, the query string does not return the
> expected
> results e.g.
>
> http://localhost/GSContracts/SearchR...ateTo=29/08/07
>
> When going to the page first time, the query string returns values as
> seen,
> but when going back to the page dateFrom returns "" and dateTo returns
> Nothing.
>
> I've guessed that it's something to do with the fact that a post back is
> processed through javascript and javascript may not recognise the /
> character?? Like I said, total guesswork... so I've used some shared
> global
> variables in my application to get around this problem.
>
> This works fine, but I'm sure there's a more elegant solution? Perhaps, if
> I'm right, there's a format I should be using for dates in query strings,
> so
> javascript can process it?
>
> Thanks in advance.



 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      08-29-2007
On Aug 29, 3:44 pm, Julia B <Jul...@discussions.microsoft.com> wrote:
> I've guessed that it's something to do with the fact that a post back is
> processed through javascript and javascript may not recognise the /
> character?? Like I said, total guesswork... so I've used some shared global


Would be good to the code where you do it

In general, / has to be passed as %2F and then decoded in the asp.net
code using HttpUtility.UrlDecode if necessary

 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      08-29-2007
"Julia B" <> wrote in message
news:C9CCA1D8-C8F7-4A85-8B3A-...

> This works fine, but I'm sure there's a more elegant solution? Perhaps, if
> I'm right, there's a format I should be using for dates in query strings,
> so
> javascript can process it?


Yes, definitely!

Firstly, you're quite right about the forward slash character - try to avoid
that if you possibly can - hyphens are nomally good in URLs and
QueryStrings...

Secondly, you need to make sure that your dates are Y2k-compliant and
unambiguous e.g. 02/03/07 is no use at all - which element is the year,
which the month and which the date?

Thirdly, 00/00/00 isn't even a valid date - using something else to
represent a blank or missing date e.g. null

&dateFrom=null&dateTo=29-Aug-2007


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

 
Reply With Quote
 
=?Utf-8?B?SnVsaWEgQg==?=
Guest
Posts: n/a
 
      08-29-2007
Thanks for this. I will remember this in future and ensure that I don't use /
in query strings again.

"Alexey Smirnov" wrote:

> On Aug 29, 3:44 pm, Julia B <Jul...@discussions.microsoft.com> wrote:
> > I've guessed that it's something to do with the fact that a post back is
> > processed through javascript and javascript may not recognise the /
> > character?? Like I said, total guesswork... so I've used some shared global

>
> Would be good to the code where you do it
>
> In general, / has to be passed as %2F and then decoded in the asp.net
> code using HttpUtility.UrlDecode if necessary
>
>

 
Reply With Quote
 
=?Utf-8?B?SnVsaWEgQg==?=
Guest
Posts: n/a
 
      08-29-2007
Hi, thanks, I'll not use / again in query strings. At least I know for
certain that it's that.

I am aware of the dates issue, I process them and ensure that they are
correct when using them.

Julia

"Mark Rae [MVP]" wrote:

> "Julia B" <> wrote in message
> news:C9CCA1D8-C8F7-4A85-8B3A-...
>
> > This works fine, but I'm sure there's a more elegant solution? Perhaps, if
> > I'm right, there's a format I should be using for dates in query strings,
> > so
> > javascript can process it?

>
> Yes, definitely!
>
> Firstly, you're quite right about the forward slash character - try to avoid
> that if you possibly can - hyphens are nomally good in URLs and
> QueryStrings...
>
> Secondly, you need to make sure that your dates are Y2k-compliant and
> unambiguous e.g. 02/03/07 is no use at all - which element is the year,
> which the month and which the date?
>
> Thirdly, 00/00/00 isn't even a valid date - using something else to
> represent a blank or missing date e.g. null
>
> &dateFrom=null&dateTo=29-Aug-2007
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to convert url with query string to url without query string nick Javascript 1 02-13-2011 11:20 PM
Date Manipulation: Week_Number back to Date wls Perl Misc 3 02-02-2005 06:48 AM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Given a date, how to find the beginning date and ending date of that week Matt ASP .Net 1 11-08-2003 09:14 PM
Given a date, how to find the beginning date and ending date of that week Matt C++ 2 11-08-2003 08:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57