The basic difference between ASP and ASP.NET is that ASP is interpreted; whereas, ASP.NET is compiled. This implies that since ASP uses VBScript; therefore, when an ASP page is executed, it is interpreted. On the other hand, ASP.NET uses .NET languages, such as C# and VB.NET, which are compiled to Microsoft Intermediate Language (MSIL).
Server controls: The server controls are Hypertext Markup Language (HTML) elements that include a runat=server attribute. They provide automatic state management and server-side events and respond to the user events by executing event handler on the server. HTML controls: These controls also respond to the user events but the events processing happen on the client machine. Data controls: Data controls allow to connect to the database execute command and retrieve data from database. System components: System components provide access to system-level events that occur on the server.
The Page_Loadevent determines that all the controls on the page are fully loaded. You can also access the controls in the Page_Init event; however, the ViewStateproperty does not load completely during this event.
You can easily traverse all controls on a form via the Web Form’s Controls collection. The GetType method can be used on each control to determine its type and how to work with it. Now, it gets tricky because the form contains a tree of controls; that is, some controls are contained within others (think of a Table). You would have to recursively loop through the controls to make sure everything is processed.
You need to set the AutoPostBackproperty to True to implement the PostBackproperty of controls.
The Page object uses the IsPostBack property to check whether the page is posted back or not. If the page is postback, this property is set to true.
State is quite an innovative concept in Web development because it eliminates the drawback of losing state data due to reloading of a Web page. By using states in a Web application, you can preserve the state of the application either at the server or client end. The state of a Web application helps you to store the runtime changes that have been made to the Web application. For example, as already described earlier, a change in the data source of the Web application might be initiated by a user when he/she selects and saves some products in the shopping cart.
If you are not using states, these changes are discarded and are not saved. You may think that the whole concept of storing states is optional. However, under certain circumstances, using states with applications is imperative. For example, it is necessary to store states for Web applications, such as an e-commerce shopping site or an Intranet site of a company, to keep track of the requests of the users for the items they have selected on the shopping site or the days requested for vacation on the Intranet site.
State management is used to store information requests. The state management is used to trace the information or data that affect the state of the applications. There are two ways to maintain a state in .NET, Client-Based state management and Server-Based state management. The following techniques can be used to implement the Client-Based state management:
The following techniques can be used to implement Server-Based state management:
Basically, View State is how ASP.NET Web pages persists data across requests. It handles data that must be preserved between postbacks, and you can use it to store page-specific data. By default, View State is enabled on a page and its controls. This can be a problem as the amount of data and controls on a page increases resulting in more data for ASP.NET to maintain. This is accomplished via the hidden __VIEWSTATE field on a form (look at the page source in a browser), so more data in this field means a slower load time and slower overall processing, as it has to be posted to the server each time. You can limit the size of the data in View State by disabling controls that do not need to be persisted via the EnableViewState property. View State can be encrypted to address security concerns.