Date string problem in query string when posting back

Discussion in 'ASP .Net' started by =?Utf-8?B?SnVsaWEgQg==?=, Aug 29, 2007.

  1. 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.
    =?Utf-8?B?SnVsaWEgQg==?=, Aug 29, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?SnVsaWEgQg==?=

    Patrice Guest

    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: ...
    > 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.
    Patrice, Aug 29, 2007
    #2
    1. Advertising

  3. On Aug 29, 3:44 pm, Julia B <> 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
    Alexey Smirnov, Aug 29, 2007
    #3
  4. "Julia B" <> wrote in message
    news:...

    > 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
    Mark Rae [MVP], Aug 29, 2007
    #4
  5. 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 <> 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
    >
    >
    =?Utf-8?B?SnVsaWEgQg==?=, Aug 29, 2007
    #5
  6. 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:...
    >
    > > 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
    >
    >
    =?Utf-8?B?SnVsaWEgQg==?=, Aug 29, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    597
    Matthew Speed
    Nov 8, 2003
  2. alanb
    Replies:
    2
    Views:
    523
    alanb
    Apr 23, 2004
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,250
    Michael Borgwardt
    May 30, 2004
  4. AmitKu
    Replies:
    7
    Views:
    499
    John Timney \(MVP\)
    Jan 8, 2007
  5. wls
    Replies:
    3
    Views:
    116
    brian d foy
    Feb 2, 2005
Loading...

Share This Page