Refreshing a page programatically

Discussion in 'ASP .Net' started by Simon Harvey, Apr 2, 2004.

  1. Simon Harvey

    Simon Harvey Guest

    HI all,

    Does anyone know how I can make a page refresh itself programatically if a
    given event is fired.

    I thought there would be some method like doPostBack() or something but I
    can't see anything like that

    Thanks

    All

    Simon
    Simon Harvey, Apr 2, 2004
    #1
    1. Advertising

  2. Simon Harvey

    Guest Guest

    Response.Redirect is used to direct the web page somewhere
    Request.ServerVariable["SCRIPT_NAME"] is a Server Variable that holds the
    path used to access the web page
    eg /WebApplication1/WebForm1.aspx
    the / Forces it to go to the root directory thus it will reload itself

    Response.Redirect(Request.ServerVariables["SCRIPT_NAME"]);
    return;
    The above code forces a page to reloads itself. Just be careful where you
    put it otherwise you will end up in a never ending loop ;)
    As a general rule you should also put a return; right after the code so no
    other code accidentally gets executed.

    Hope this helps.
    This posting is provided as is.



    "Simon Harvey" <> wrote in message
    news:OTms%...
    > HI all,
    >
    > Does anyone know how I can make a page refresh itself programatically if a
    > given event is fired.
    >
    > I thought there would be some method like doPostBack() or something but I
    > can't see anything like that
    >
    > Thanks
    >
    > All
    >
    > Simon
    >
    >
    Guest, Apr 2, 2004
    #2
    1. Advertising

  3. Simon Harvey

    Simon Harvey Guest

    Hi there,

    Thanks for your help.

    One thing I'm wondering about what you suggest is if this approach to the
    problem would result in the same type of refresh as a postback. For example,
    what would happen with the viewstate?

    Thanks again

    Simon
    Simon Harvey, Apr 2, 2004
    #3
    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. Milsnips
    Replies:
    1
    Views:
    562
    =?Utf-8?B?Z3VpbGxhdW1lIFN0RXRpZW5uZSBGUg==?=
    May 16, 2005
  2. Harlan Messinger

    Self-refreshing and non-self-refreshing controls

    Harlan Messinger, Aug 4, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    447
    =?Utf-8?B?Y2xpY2tvbg==?=
    Aug 4, 2006
  3. Bali
    Replies:
    0
    Views:
    426
  4. Harlan Messinger

    Self-refreshing and non-self-refreshing controls

    Harlan Messinger, Aug 3, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    180
    Harlan Messinger
    Aug 3, 2006
  5. Replies:
    2
    Views:
    125
Loading...

Share This Page