C # Real-time Read Data----Local page refresh "Go"

Source: Internet
Author: User

I) just started to learn C #, some basic controls do not know enough, there is a real-time monitoring system, need to refresh the data on the page every 5 seconds,

If every 5 seconds page all refresh, that page can not see at all, to this question in CSDN also specially opened a post, asked everyone master,

Posts: http://topic.csdn.net/u/20100109/23/812355fb-32ce-4e3b-98ec-be80c630e1d5.html

II) The basic idea of realization:

With Microsoft Ajax easy to achieve!!
1. Drag into the ScriptManager;
2. Drag into UpdatePanel
3. Add a timer timer, set INTERVQL to 5 seconds (5000)
4. Add a Data control, depending on the needs of the GridView or DataList, etc., connect the database
5. Set UpdatePanel to conditional asynchronous update
6. Enter the code in the timer's tick event
protected void Timer1_Tick (object sender, EventArgs e)
{
Updatepanel1.update ();
Gridview1.databind ();//If the display data is a GridView
}

III) Specific implementations:

<asp:scriptmanager id= "ScriptManager1" runat= "Server" >  </asp:ScriptManager>  <asp: UpdatePanel id= "UpdatePanel1" runat= "Server" >  <ContentTemplate>  <%= DateTime.Now.ToString ()% >  <!--the GridView control is bound in the background--->  <asp:gridview id= "GridView1" runat= "Server" >  </asp: Gridview>  <!--timer refreshes the data in UpdatePanel once every 5 seconds--  <asp:timer id= "Timer1" runat= "Server" interval= " ">  </asp:Timer>  </ContentTemplate>  <Triggers>  <asp: Asyncpostbacktrigger controlid= "Timer1" eventname= "Tick" ></asp:AsyncPostBackTrigger>  </triggers >  </asp:UpdatePanel>

C # Real-time Read Data----Local page refresh "Go"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.