By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,414 Members | 2,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,414 IT Pros & Developers. It's quick & easy.

Date string problem in query string when posting back

P: n/a
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.
Aug 29 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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" <Ju****@discussions.microsoft.coma écrit dans le message de
news: C9**********************************@microsoft.com...
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.

Aug 29 '07 #2

P: n/a
On Aug 29, 3:44 pm, Julia B <Jul...@discussions.microsoft.comwrote:
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

Aug 29 '07 #3

P: n/a
"Julia B" <Ju****@discussions.microsoft.comwrote in message
news:C9**********************************@microsof t.com...
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

Aug 29 '07 #4

P: n/a
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.comwrote:
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

Aug 29 '07 #5

P: n/a
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" <Ju****@discussions.microsoft.comwrote in message
news:C9**********************************@microsof t.com...
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

Aug 29 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.