Problem:
There is a control on webform, which is best to be able to access the database in real time. Once there is a change in the database, it submits data to the client and displays the latest data.
Analysis:
Because the client needs to be updated, the front-end clock function of JS must be used. The server has changed, and the client needs to be refreshed to update the data. How can we not refresh the data or refresh the page falsely, that is, the client can hardly see the refresh.
Solution: (Please correct the error. I am at a limited level. Thank you)
There are two main solutions: Real-Time and round-robin.
Real-time: a trigger is added to the database to trigger the trigger. Then, a file is written to the server and used as a semaphore. I think this technology is too complicated to address this problem, so I didn't continue to study it. If you are interested, you can go to msdn to check it, but you can update data in real time, it is most effective for instant conversations.
Round robin: 1. The new XMLHTTP method is used. In this way, you can refer to what someone else wrote in front of me.Article , Which has a detailed introduction, but after I tested it, I found that the HTML of the entire page is obtained from the server. Code To get the control content you need, and the reset is still too complicated, and the efficiency is not necessarily high.
2. Use the HTML framework, that is, the method I mainly write. This method is simple and easy to implement. I think it is very useful to dynamically display small data.
For more information, see <IFRAME src = ".. /test/webform2.aspx "> </iframe> SRC is the page to be connected, and then adjust the frame size and the scroll bar as needed.
Create a new page webform2.aspx, which is used as the connection page of the Framework. Place the control to be updated in real time in the page, and then in the page_load event.
Private sub page_load (byval sender as system. Object, byval e as system. eventargs) handles mybase. Load
'Place the code for obtaining database updates here and associate it with the control.
End sub
Add <meta HTTP-EQUIV = "refresh" content = "1" url = "/test/webform2.aspx">
Indicates that the page is automatically refreshed every one second (you can also add a window as needed. setinterval (function, 1000) and other front-end clocks). The result is complete. After the first page is started, the second page does not Refresh after a while, however, the client feels the same as it does not refresh.