Date string problem in query string when posting back

G

Guest

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/Search...otesAll=Yes&dateFrom=00/00/00&dateTo=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.
 
P

Patrice

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).
 
G

Guest

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
 
M

Mark Rae [MVP]

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
 
G

Guest

Thanks for this. I will remember this in future and ensure that I don't use /
in query strings again.
 
G

Guest

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top