Should this code force a refresh of my asp.net page?

Discussion in 'ASP .Net' started by COHENMARVIN@lycos.com, May 2, 2008.

  1. Guest

    I have a button in my asp.net page (actually its in a user control
    with a .ASCX suffix) called btnGetData. I'm trying to make it force a
    refresh of my page. So what I did was make it call javascript.
    Should the following work? (It doesn't seem to)

    Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles btnGetData.Click
    LoadGridView()
    ForcePageRefresh()
    End Sub


    Sub ForcePageRefresh()
    Dim popupScript As String
    Dim instance As ClientScriptManager

    instance = Page.ClientScript
    popupScript = "<script language='JavaScript'>"
    popupScript = popupScript & "
    window.location.reload( true );"
    popupScript = popupScript & "</script>"
    instance.RegisterStartupScript(GetType(String), "PopupScript",
    popupScript)
    End Sub
    , May 2, 2008
    #1
    1. Advertising

  2. bruce barker Guest

    have no idea why on a postback, your code would render a command to request
    the same page again to get the html, instead of returning the correct html
    (sloppy coding I guess). you can just use Response.Redirect, no need for
    javascript.

    for either approach to work you shoudl decorate the url (add a dummay
    parameter) to force a fresh copy rather than using a cached copy.

    -- bruce (sqlwork.com)


    "" wrote:

    > I have a button in my asp.net page (actually its in a user control
    > with a .ASCX suffix) called btnGetData. I'm trying to make it force a
    > refresh of my page. So what I did was make it call javascript.
    > Should the following work? (It doesn't seem to)
    >
    > Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles btnGetData.Click
    > LoadGridView()
    > ForcePageRefresh()
    > End Sub
    >
    >
    > Sub ForcePageRefresh()
    > Dim popupScript As String
    > Dim instance As ClientScriptManager
    >
    > instance = Page.ClientScript
    > popupScript = "<script language='JavaScript'>"
    > popupScript = popupScript & "
    > window.location.reload( true );"
    > popupScript = popupScript & "</script>"
    > instance.RegisterStartupScript(GetType(String), "PopupScript",
    > popupScript)
    > End Sub
    >
    bruce barker, May 2, 2008
    #2
    1. Advertising

  3. Stan Guest

    On 2 May, 15:38, wrote:
    > I have a button in my asp.net page (actually its in a user control
    > with a .ASCX suffix) called btnGetData.  I'm trying to make it force a
    > refresh of my page.  So what I did was make it call javascript.
    > Should the following work?  (It doesn't seem to)
    >
    >   Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles btnGetData.Click
    >         LoadGridView()
    >         ForcePageRefresh()
    >     End Sub
    >
    >     Sub ForcePageRefresh()
    >         Dim popupScript As String
    >         Dim instance As ClientScriptManager
    >
    >         instance = Page.ClientScript
    >         popupScript = "<script language='JavaScript'>"
    >         popupScript = popupScript & "
    > window.location.reload( true );"
    >         popupScript = popupScript & "</script>"
    >         instance.RegisterStartupScript(GetType(String), "PopupScript",
    > popupScript)
    >     End Sub


    Hi

    I am intrigued as to why you want to do this. Could it be that you are
    trying to trigger execution of code on the host page when a User
    Control button is clicked?
    Stan, May 2, 2008
    #3
  4. Niraj Ranka Guest

    Can you give the reason why u want to reload the same (loading) page again n
    again ?

    <> wrote in message
    news:...
    >I have a button in my asp.net page (actually its in a user control
    > with a .ASCX suffix) called btnGetData. I'm trying to make it force a
    > refresh of my page. So what I did was make it call javascript.
    > Should the following work? (It doesn't seem to)
    >
    > Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles btnGetData.Click
    > LoadGridView()
    > ForcePageRefresh()
    > End Sub
    >
    >
    > Sub ForcePageRefresh()
    > Dim popupScript As String
    > Dim instance As ClientScriptManager
    >
    > instance = Page.ClientScript
    > popupScript = "<script language='JavaScript'>"
    > popupScript = popupScript & "
    > window.location.reload( true );"
    > popupScript = popupScript & "</script>"
    > instance.RegisterStartupScript(GetType(String), "PopupScript",
    > popupScript)
    > End Sub
    Niraj Ranka, May 3, 2008
    #4
  5. Guest

    > > I have a button in my asp.net page (actually its in a user control
    > > with a .ASCX suffix) called btnGetData. I'm trying to make it force a
    > > refresh of my page. So what I did was make it call javascript.

    >
    > Hi
    > I am intrigued as to why you want to do this. Could it be that you are
    > trying to trigger execution of code on the host page when a User
    > Control button is clicked?


    The reason I wanted to force a refresh was that I noticed my gridview
    was only showing up when the page was refreshed. It wasn't enough to
    set its parameters and then do a 'databind' - the gridview would only
    appear on a postback. I really don't understand why this is the case,
    and even when I stepped through with the debugger everything seemed in
    order - but the gridview would not appear. So I decided to cheat, and
    force a refresh.
    The page does use AJAX, and perhaps that has some bug that causes the
    problem.
    -- Marvin
    , May 4, 2008
    #5
    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. qqq
    Replies:
    4
    Views:
    16,661
    toddbailey
    Apr 24, 2009
  2. =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=

    force asp.net to remove cached page literals asp.net 1.1

    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=, Jul 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    540
    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=
    Jul 5, 2005
  3. Paul Drummond

    How to force a page refresh?

    Paul Drummond, Jan 4, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    7,252
    Joerg Jooss
    Jan 4, 2006
  4. Moo

    force page to refresh

    Moo, Apr 20, 2005, in forum: HTML
    Replies:
    2
    Views:
    12,548
    David Dorward
    Apr 20, 2005
  5. Hrvoje Vrbanc
    Replies:
    4
    Views:
    7,334
    Hrvoje Vrbanc
    May 22, 2008
Loading...

Share This Page