I have gridview in update panel and i am doing post back after two seconds to update panel like this
<script language="javascript" type="text/javascript">
window.setInterval(function () {
__doPostBack('<%= UpdatePanel1.ClientID %>', '');
}, 2000);
</script>
and on server side i used this code to load grid on each postback
if (IsPostBack)
{
GridView2.DataBind();
SqlDataSource1.DataBind();
}
It Load the Gridview after tow seconds accordingly.But Problem is that it didn't work on a bit slow internet connection or also making load on web server i only want to ask that is there any alternative on client end or with javascript so it should do all on client level not on server level.Plz give any better idea
To be blunt, this is about the worst possible use of an UpdatePanel
. You are rendering the entire page (behind the scenes) just to update that panel every 2 seconds.
There are a few alternatives:
All of these approaches will not require the page to be rendered, just the content that you actually need. Thus, they are immediately more efficient.
Options #2 and #3 will require a little manual JavaScript to make the AJAX call. jQuery works nicely for this.
However, you still are dealing with the fact that you must poll the server every few seconds. To avoid this, you may want to read about long polling to achieve push notifications instead.
See also: ASP.Net SignalR