[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 562
  • Last Modified:

ASP.NET refresh the data every 15 sec and retain the values already populated in the page

ASP.NET
I am using    <meta http-equiv="refresh" content="300">
for refreshing the auto refreshing the page in ASP.NET
, however the values of the list and text box get lost when i do this.

i tried using enableviewstate but still the values are not retained.
is there any way i can auto refresh the data of a page after every 15 sec and retain the values already populated in the page
0
kurtcobain123
Asked:
kurtcobain123
  • 5
  • 4
1 Solution
 
Bob LearnedCommented:
How are you binding the data in the Page_Load event?

Bob
0
 
kurtcobain123Author Commented:
i call a function for binding the data

rdDisplay_SelectedIndexChanged(null,System.EventArgs.Empty);


which has all the dataloading functions... based on selection of the radiobutton.
the problem is that this selection gets lost if i use the meta tag

AB
0
 
Bob LearnedCommented:
When the refresh occurs, the page is reloaded.  Can you show me the rdDisplay_SelectedIndexChanged code, and the Page_Load, please?

Bob
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
kurtcobain123Author Commented:
here u go .....
#region Page_Load
            private void Page_Load(object sender, System.EventArgs e)
            {

                  if (!Page.IsPostBack)
                  {
                        rdDisplay.SelectedIndex = 0;
                  }

                  OracleConnection oConn = new OracleConnection(System.Configuration.ConfigurationSettings.AppSettings["dbConnection"]);
                  oConn.Open();
                  OracleCommand cmd = oConn.CreateCommand();
                  string SQLString =  " select to_char(sysdate,'dd Mon yy hh24:mi:ss') as dt from dual " ;
                  OracleCommand oCmd = new OracleCommand(SQLString, oConn);
                  
                  DataSet ds = new DataSet();
                  OracleDataAdapter adapter = new OracleDataAdapter(oCmd);
                  adapter.Fill(ds);
                  LblRefreshdate.Text = ds.Tables[0].Rows[0].ItemArray[0].ToString();
                  oConn.Close();
                  rdDisplay_SelectedIndexChanged(null,System.EventArgs.Empty);


            }
            #endregion

#region rdDisplay_SelectedIndexChanged
            private void rdDisplay_SelectedIndexChanged(object sender, System.EventArgs e)
            {
                  if(rdDisplay.SelectedIndex == 0)  //all
                  {
                        btnShow.Visible = false;
                        ScheduleGeneral1.FullTimeScale = false;
                        txtTimeInterval.Visible = false;
                        lblTimeInterval.Visible = false;
                        txtTimeInterval.Text = "60";
                        BindData();
                  }
}
            #endregion

Thanks
0
 
Bob LearnedCommented:
Troubleshooting check:

1) Can you put breakpoints when running?

2) Put a breakpoint in the Page_Load, and check the value of the controls to see if they are what you expect before anything else is done.  My guess is that they are fine, and something else later is messing it up

3) I create a small test with a single control, and a meta refresh, and after the post-back the state of the control was kept.

Bob
0
 
kurtcobain123Author Commented:
I tried but am loosing the viewstate info i think this is because the meta refresh doesn't cause a postback. Rather,it's a completely new page request.

neideas how to do this using javascript timer fn ?
0
 
Bob LearnedCommented:
</body>

<script language='Javascript'>
setTimeout(Refresh, 15000);

function Refresh()
{
  __doPostBack('Dummy', '');
}
</script>

Bob
0
 
kurtcobain123Author Commented:
Found a solution....

setTimeout("Form1.submit()",30000);

works !

0
 
kurtcobain123Author Commented:
Thanks Bob
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now