Although you are likely to want to use the Web Forms Frames to save time and code, it is not appropriate to use ASP.NET server controls and rapid restructuring in some cases.
Typically, you only need to boot to the server's round-trip process when retrieving or storeing data. Most data operations can be performed on the clients between these round-trip processes. For example, verifying user inputs from an HTML form often proceeds before the data is submitted to the server. Typically, if you don't need to pass the information to the server to store it in the database, then you should not write code that causes the round-trip process.
If you develop a custom server control, consider rendering client code for your browser that supports Ecmascript. By using server controls in this way, you can significantly reduce the number of information that is unnecessary to send to the web server. Use Page.isPostback to avoid unnecessary processing on the round-trip process If you write code for processing server control retrace processing, you may need to perform other code when you first request a page instead of sending HTML windows included in this page. The code performed by the body. Depending on whether the page is generated by the response server control event, use the page.ispostback attribute to execute the code. For example, the following code demonstrates how to create a database connection and command, which is bound to the DataGrid server control when requested the page for the first time. [Visual Basic] Sub Page_Load (sender As Object, e As EventArgs) 'Set up a connection and command here.If Not (Page.IsPostBack) Dim query As String = "select * from Authors where FirstName like'% JUSTIN% '" MyCommand.Fill (DS, "Authors") MyDataGrid.Database () end iFend Sub
[C #] void Page_Load (Object sender, EventArgs e) {// Set up a connection and command here.if (Page.IsPostBack!) {String query = "select * from Authors where FirstName like '% JUSTIN%'"; myCommand .Fill (DS, "Authors"); mydatagrid.database ();}} Due to each request, the Page_Load event is executed, and the above code checks if the iSPostBack property is set to false. If yes, execute the code. If this property is set to True, the code is not executed. Note If this check is not running, the behavior of the back page will not change. The code for the Page_Load event is executed before executing the server control event, but only the result of the server control event may be rendered on the output page. If you do not run this check, you will still perform processing for the Page_Load event and any server control event on the page.