Presentation is loading. Please wait.

Presentation is loading. Please wait.

Session 4: HTML and Web Server Controls. Outline Creating Web Forms Using Server Controls HTML Server Controls Web Server Controls Writing ASP Code Inline.

Similar presentations


Presentation on theme: "Session 4: HTML and Web Server Controls. Outline Creating Web Forms Using Server Controls HTML Server Controls Web Server Controls Writing ASP Code Inline."— Presentation transcript:

1 Session 4: HTML and Web Server Controls

2 Outline Creating Web Forms Using Server Controls HTML Server Controls Web Server Controls Writing ASP Code Inline Code Code behind pages Event Procedures Using Page Events

3 What Is a Web Form?.aspx extension Page attributes @ Page directive Body attributes Form attributes

4 What is a Server Control? Runat="server" Events happen on the server View state saved Have built-in functionality Common object model All have Id and Text attributes Create browser-specific HTML <asp:Button id="Button1" runat="server" Text="Submit"/> <asp:Button id="Button1" runat="server" Text="Submit"/>

5 Types of Server Controls HTML server controls Web server controls Intrinsic controls Validation controls Rich controls List-bound controls Internet Explorer Web controls

6 HTML Server Controls Based on HTML elements Exist within the System.Web.UI.HtmlControls namespace

7 Web Server Controls Exist within the System.Web.UI.WebControls namespace Control syntax HTML that is generated by the control <asp:TextBox id="TextBox1" runat="server">Text_to_Display <asp:TextBox id="TextBox1" runat="server">Text_to_Display <input name="TextBox1" type="text" value="Text_to_Display" Id="TextBox1"/> <input name="TextBox1" type="text" value="Text_to_Display" Id="TextBox1"/>

8 You need specific functionality such as a calendar or ad rotator The control will interact with client and server script You are writing a page that might be used by a variety of browsers You are working with existing HTML pages and want to quickly add ASP.NET Web page functionality You prefer a Visual Basic-like programming model You prefer an HTML-like object model Use Web Server Controls if: Use HTML Server Controls if: Bandwidth is not a problemBandwidth is limited Selecting the Appropriate Control

9 Writing ASP.NET Code: Inline Code Code and content in the same file Different sections in the file for code and HTML Sub btn_Click(s As Object, e As EventArgs) Handles btn.Click... End Sub Sub btn_Click(s As Object, e As EventArgs) Handles btn.Click... End Sub

10 Writing ASP.NET Code: Code-Behind Pages Separation of code from content Developers and UI designers can work independently Form1.aspxForm1.aspx Form1.aspx.vb Form1.aspx.vb or Form1.aspx.cs code code Separate filesSingle file

11 Understanding How Code-Behind Pages Work Create separate files for user interface and interface logic Use @ Page directive to link the two files Pre-compile or JIT-compile Page1.aspx Page1.aspx.cs public class WebForm1 { private void cmd1_Click() { … }


Download ppt "Session 4: HTML and Web Server Controls. Outline Creating Web Forms Using Server Controls HTML Server Controls Web Server Controls Writing ASP Code Inline."

Similar presentations


Ads by Google