J
Jeronimo Bertran
I have a DataGrid that gets filled based on a filter which is defined by
the values that the user selects on several controls. When the page
postbacks after changing the selection on the filter controls, the DataGrid
refreshes itslef. Now, I also need to refresh the DataGrid if I detect
that something "external" has changed (keeping the filter that the user is
using).
For this, I have created a page that partially refreshes itslef in order to
determine if a datagrid must be refreshed. I created a frame within my page
<iframe id='AutoRefresh' src='MonitorAutoRefresh.aspx></iframe>
where MonitorAutoRefresh includes a <meta http-equiv='refresh' content=" +
ResponseTime.ToString() + ">"
MonitorAutorRefresh Page_Load does the following:
// Check if the main grid needs to be refreshed
if (RefreshNeeded())
{
Page.RegisterStartupScript("RefreshParent", "<script
language='javascript'>\r\nRefreshParent()\r\n</script>\r\n");
}
and the script RefreshParent is defined as:
function RefreshParent()
{
window.parent.location.href = window.parent.location.href;
}
The problem I have is that since I am refreshing the parent, I am losing
the state information of the filter controls, and thus the grid gets
refreshed using the default values.
Can I force a postback on the main page to be generated from the
MonitorAutoRefresh panel instead of calling my RefreshParent (which would
preserve the values on the filter controls)? Or, do I need to store the
control values on a session variable in order to preserve them after
calling RefreshParent? Or is there a better solution to what I am trying to
do?
Thanks,
Jeronimo
the values that the user selects on several controls. When the page
postbacks after changing the selection on the filter controls, the DataGrid
refreshes itslef. Now, I also need to refresh the DataGrid if I detect
that something "external" has changed (keeping the filter that the user is
using).
For this, I have created a page that partially refreshes itslef in order to
determine if a datagrid must be refreshed. I created a frame within my page
<iframe id='AutoRefresh' src='MonitorAutoRefresh.aspx></iframe>
where MonitorAutoRefresh includes a <meta http-equiv='refresh' content=" +
ResponseTime.ToString() + ">"
MonitorAutorRefresh Page_Load does the following:
// Check if the main grid needs to be refreshed
if (RefreshNeeded())
{
Page.RegisterStartupScript("RefreshParent", "<script
language='javascript'>\r\nRefreshParent()\r\n</script>\r\n");
}
and the script RefreshParent is defined as:
function RefreshParent()
{
window.parent.location.href = window.parent.location.href;
}
The problem I have is that since I am refreshing the parent, I am losing
the state information of the filter controls, and thus the grid gets
refreshed using the default values.
Can I force a postback on the main page to be generated from the
MonitorAutoRefresh panel instead of calling my RefreshParent (which would
preserve the values on the filter controls)? Or, do I need to store the
control values on a session variable in order to preserve them after
calling RefreshParent? Or is there a better solution to what I am trying to
do?
Thanks,
Jeronimo