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 / August 2007

Tip: Looking for answers? Try searching our database.

Date string problem in query string when posting back

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Julia B - 29 Aug 2007 14:44 GMT
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/SearchResults.aspx?quoteID=0&quotesAll=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.
Patrice - 29 Aug 2007 14:52 GMT
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

> Hi,
>
[quoted text clipped - 30 lines]
>
> Thanks in advance.
Alexey Smirnov - 29 Aug 2007 14:56 GMT
> 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
Julia B - 29 Aug 2007 15:06 GMT
Thanks for this. I will remember this in future and ensure that I don't use /
in query strings again.

> > 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 /
[quoted text clipped - 4 lines]
> In general, / has to be passed as %2F and then decoded in the asp.net
> code using HttpUtility.UrlDecode if necessary
Mark Rae [MVP] - 29 Aug 2007 14:58 GMT
> 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

Signature

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

Julia B - 29 Aug 2007 15:08 GMT
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

> > 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,
[quoted text clipped - 15 lines]
>
> &dateFrom=null&dateTo=29-Aug-2007

Rate this thread:







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.