Force a complete reload of a page.

Discussion in 'ASP .Net' started by UJ, Jul 12, 2006.

  1. UJ

    UJ Guest

    Is there any way I can have a page reload itself where it will completely
    reload from scratch. I have a condition where a person click a button and
    the easiest way to handle it would be to have the button do the DB stuff it
    needs to do and then load the page from scratch - not post back.

    I've tried putting in a server.transfer in the routine that does the button
    click but it seems to get into an infinite loop.

    TIA - Jeff.
    UJ, Jul 12, 2006
    #1
    1. Advertising

  2. UJ

    Guest

    Hey Jeff,
    Just create a javascript function to refresh the page. Then just add
    that function to the asp.net button using
    'Btn.Attributes.Add("onclick","your js function name")

    Thanks

    UJ wrote:
    > Is there any way I can have a page reload itself where it will completely
    > reload from scratch. I have a condition where a person click a button and
    > the easiest way to handle it would be to have the button do the DB stuff it
    > needs to do and then load the page from scratch - not post back.
    >
    > I've tried putting in a server.transfer in the routine that does the button
    > click but it seems to get into an infinite loop.
    >
    > TIA - Jeff.
    , Jul 12, 2006
    #2
    1. Advertising

  3. And the javascript will be

    location.reload(true);

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]

    <> wrote in message
    news:...
    > Hey Jeff,
    > Just create a javascript function to refresh the page. Then just add
    > that function to the asp.net button using
    > 'Btn.Attributes.Add("onclick","your js function name")
    >
    > Thanks
    >
    > UJ wrote:
    >> Is there any way I can have a page reload itself where it will completely
    >> reload from scratch. I have a condition where a person click a button and
    >> the easiest way to handle it would be to have the button do the DB stuff
    >> it
    >> needs to do and then load the page from scratch - not post back.
    >>
    >> I've tried putting in a server.transfer in the routine that does the
    >> button
    >> click but it seems to get into an infinite loop.
    >>
    >> TIA - Jeff.

    >
    Eliyahu Goldin, Jul 13, 2006
    #3
  4. UJ

    UJ Guest

    Actually I do a response.redirect to itself and it works great.

    Thanks anyway.

    "Eliyahu Goldin" <> wrote in message
    news:...
    > And the javascript will be
    >
    > location.reload(true);
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    >
    > <> wrote in message
    > news:...
    >> Hey Jeff,
    >> Just create a javascript function to refresh the page. Then just add
    >> that function to the asp.net button using
    >> 'Btn.Attributes.Add("onclick","your js function name")
    >>
    >> Thanks
    >>
    >> UJ wrote:
    >>> Is there any way I can have a page reload itself where it will
    >>> completely
    >>> reload from scratch. I have a condition where a person click a button
    >>> and
    >>> the easiest way to handle it would be to have the button do the DB stuff
    >>> it
    >>> needs to do and then load the page from scratch - not post back.
    >>>
    >>> I've tried putting in a server.transfer in the routine that does the
    >>> button
    >>> click but it seems to get into an infinite loop.
    >>>
    >>> TIA - Jeff.

    >>

    >
    >
    UJ, Jul 13, 2006
    #4
  5. UJ

    Flyte

    Joined:
    Aug 22, 2008
    Messages:
    1
    Excellent, I've been wrestling with viewstate for ages trying to get it to reload the values of text boxes from the DB, but this is a simple, quick and easy solution to all my problems!

    Cheers :barresed:
    Flyte, Aug 22, 2008
    #5
  6. UJ

    Minakovic

    Joined:
    Feb 27, 2009
    Messages:
    1
    Try this instead of Response.Redirect, It works perfectly well....

    Response.AddHeader "Refresh", "0;URL=default.asp"

    This will reload the page specified, if you want to use it to reload the same page after executing some scripting you can use a variable....

    If PageStatus = "reload" Then
    Response.AddHeader "Refresh", "0;URL=SamePage.asp"
    PageStatus = ""
    End If

    If you are executing script on a different page, you can also pass the information and retreive it using the Querystring

    Samepage.asp?PageStatus=reload

    PageStatus = Request.QueryString("PageStatus")
    If PageStatus = "reload" Then
    Response.AddHeader "Refresh", "0;URL=SamePage.asp"
    PageStatus = ""
    End If

    * Zero is the time before reloading....
    * Do not forget to clear PageStatus otherwise you will be stuck in a loop

    Enjoy
    Minakovic, Feb 27, 2009
    #6
  7. UJ

    pcpgmr

    Joined:
    Mar 23, 2010
    Messages:
    1
    response.redirect;
    pcpgmr, Mar 23, 2010
    #7
    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. Sia Jai Sung

    Force reload of ASP page after processing

    Sia Jai Sung, Jan 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    8,163
  2. tshad

    no-cache to force reload new page

    tshad, Jul 27, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    822
    tshad
    Jul 27, 2006
  3. Nige

    Force reload of changed page?

    Nige, Nov 14, 2003, in forum: Javascript
    Replies:
    3
    Views:
    129
    Thomas 'PointedEars' Lahn
    Nov 18, 2003
  4. Mark Anderson
    Replies:
    4
    Views:
    173
    Mark Anderson
    Mar 2, 2005
  5. pbd22
    Replies:
    4
    Views:
    217
    Kailash Nadh
    Nov 29, 2007
Loading...

Share This Page