Click to See Complete Forum and Search --> : how to refresh


prasad_agv
June 15th, 2002, 06:49 AM
i want to refresh a page
programatically. That
should be refreshed
like we refresh
browser using
F5 Key.

thanks.

V. Lorenzo
June 17th, 2002, 04:59 AM
Hi:

How? By regenerating the entire page ? I see two methods of doing that.

Method 1 - Typing some JScript code. Place an HTML button in your form and (switching to HTML view in the designer, Ctrl+PgDwn) set it's OnClick event. This button is intended for being executed at the client. For the event handler insert a JavaScript code fragment (Edit/Insert Script Block/Client) like this :

function Refresh()
{
document.location.reload();
}

This code reloads the entire page.

Method 2 - Put all the page initialization code (in your page.aspx.cs file) appart in a function, say something like :

protected void RefreshData()
{ ...the data loading code here... }

so it could be called from your page's Page_Load method like:

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
RefreshData();
}
}

Insert an asp:button in your form with the ButtonClick handler calling your RefreshData() function.

That's all.

VictorL

DevDragon
September 9th, 2005, 05:10 PM
this will be sufficient in most situations...

Response.Redirect(Request.CurrentExecutionFilePath);