Web forms occupy an important and interesting concept in web development. Several basic Web controls are used to represent standard HTML form elements such as radio buttons, text boxes, and list boxes. These controls form an integral part of ASP.NET and can be primarily used in it to build user interface for Web application. ASP.NET provides programmed control over the user interface by using objects that reside on the server.
Web Forms Programming Model
Web forms pages are divided into two parts.
- Visual elements and other is
- Accompanying UI logic.
According to the concept both these elements differ from each other and they can be located physically anywhere desired. Typically, both the parts are found within one .aspx file.
The following Example shows a Web Form Model.
| Example6:
web_form_model.aspx |
<%@ Page Language="VB" %>
<script runat="server">
Sub tbMessage_Change (Sender as Object, E as EventArgs)
lblMessage. Text="Hello " + tbMessage. Text
End Sub
</script>
<html>
<body>
<font size="5">www.expertrating.com</font><hr><p>
<% Response.Write ("Our Test Page<p>") %>
<form runat="server">
Please Enter Your Name:
<asp: TextBox id="tbMessage"
OnTextChanged ="tbMessage_Change" runat="server"/>
<asp: button id="btSubmit" Text="Submit"
runat="server"/><p>
<b><asp: label id="lblMessage" runat="server"/></b>
</form>
</body>
</html> |
| |
The output of the above example is shown below: -
A typical web form is shown in the above example. The UI is found within the HTML portion of the page, the server controls are found on line 14,15, and 16.which have properties, methods, and events that can be controlled. The UI logic that is the code that controls the UI is contained in the code declaration block i.e. on line 3 to 7.
|