Presentation is loading. Please wait.

Presentation is loading. Please wait.

ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC.

Similar presentations


Presentation on theme: "ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC."— Presentation transcript:

1 ASP.Net Web Applications

2 Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC Database Server HTTP Response ASP / JSP ISAPI / NSAPI …… /……

3 Building dynamic web application Working with ASP.NET. Working with ASP.NET. Using Web Controls Using Web Controls Looking behind “The ViewState hidden field” Looking behind “The ViewState hidden field” Using Page.IsPostBack Using Page.IsPostBack Using Microsoft ADO.NET to Access Data Using Microsoft ADO.NET to Access Data Creating a Microsoft ASP.NET Web Application Creating a Microsoft ASP.NET Web Application

4 Working with ASP.NET Introducing ASP.NET Introducing ASP.NET Creating Web Forms Creating Web Forms Adding ASP.NET Code to a Page Adding ASP.NET Code to a Page Handling Page Events Handling Page Events

5 Introducing ASP.NET XML Data Database Internet Page1. aspx Page2. aspx Components Web Forms Code- behind pages global. asax Web. config machine. config ASP.NET Web Server Output Cache Browser

6 ASP.Net Execution Model

7 Creating Web Forms 1/3

8 Creating Web Forms 2/3

9 Creating Web Forms 3/3 Asp.Net Whodgey is the Microsoft next generation development tool for Asp.Net Web Applications. It is an improved mixture of Web Matrix and Visual Studio.Net.

10 Adding ASP.NET Code to a Page 1/2

11 Label Adding ASP.NET Code to a Page 2/2

12 Handling Page Events void Button1_Click(object sender, EventArgs e) { Label1.Text = TextBox1.Text; }

13 Using Web Controls What Are Web Controls? What Are Web Controls? Using Intrinsic Controls Using Intrinsic Controls Using Input Validation Controls Using Input Validation Controls Selecting Controls for Applications Selecting Controls for Applications Demo Demo

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

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

16 HTML Server Controls Based on HTML elements Based on HTML elements Exist within the System.Web.UI.HtmlCont rols namespace Exist within the System.Web.UI.HtmlCont rols namespace

17 Web Server Controls Exist within the System.Web.UI.WebControl s namespace Exist within the System.Web.UI.WebControl s namespace Control syntax HTML generated by 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"/>

18 What Is Input Validation? Verifies that a control value is correctly entered by the user Verifies that a control value is correctly entered by the user Blocks the processing of a page until all controls are valid Blocks the processing of a page until all controls are valid Avoids spoofing, or the addition of malicious code Avoids spoofing, or the addition of malicious code

19 Client-Side and Server-Side Validation ASP.NET can create both client-side and server-side validation ASP.NET can create both client-side and server-side validation Client-side validation Client-side validation Dependent on browser version Dependent on browser version Instant feedback Instant feedback Reduces postback cycles Reduces postback cycles Server-side validation Server-side validation Repeats all client-side validation Repeats all client-side validation Can validate against stored data Can validate against stored data Valid? User Enters Data No Yes Error Message Client Server Web Application Processed

20 ASP.NET Validation Controls ASP.NET provides validation controls to: Compare values Compare values Compare to a custom formula Compare to a custom formula Compare to a range Compare to a range Compare to a regular expression pattern Compare to a regular expression pattern Require a user input Require a user input Summarize the validation controls on a page Summarize the validation controls on a page

21 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 problem Bandwidth is limited Selecting the Appropriate Server Control

22 Looking under the hood “The ViewState hidden field” Hidden ViewState control of name- value pairs stored in the Web Form Hidden ViewState control of name- value pairs stored in the Web Form On by default, adjustable at Web Form and control level On by default, adjustable at Web Form and control level

23 Looking under the hood “The ViewState hidden field” 1/3 Understanding ViewState via a demo : Understanding ViewState via a demo : Add the following Web Controls a Form Add the following Web Controls a Form ASP:Text ASP:Text ASP:Lable ASP:Lable ASP:Button ASP:Button Double click the Text Box to generate the TextBox1_OnChange Event Code. Double click the Text Box to generate the TextBox1_OnChange Event Code. Inside the event code write the following code: Inside the event code write the following code: Label1.Text = System.DateTime.Now.ToLongTimeString();

24 Looking under the hood “The ViewState hidden field” 2/3 The value of TextBox1, “yosef” is being html delivered to the browser in two places. First place in This value can be changed by the user Second place within the VIEWSTATE hidden field. This value can not be changed. When the html form is being submitted the server automatically response to changes in TextBox1and generate server event.

25 Looking under the hood “The ViewState hidden field” 3/3

26 Using Page.IsPostBack

27 Using Microsoft ADO.NET to Access Data Displaying Data in the DataGrid Control Displaying Data in the DataGrid Control Using Templates Using Templates Using the Repeater Control Using the Repeater Control Using Datasets vs. DataReaders Using Datasets vs. DataReaders

28 Displaying Data in the DataGrid Control 1. Build a Connected/Disconnected Data Source 2. Bind the Data Grid to your Data Source DataGrid1.DataSource = reader1; Or DataGrid1.DataSource = DataSet1.Tables[0].DefaultView; 3. Tell The Control to generate HTML Datagrid1.DataBind();

29 The DataAdapter Object Model sp_SELECT Command SelectCommandUpdateCommandInsertCommandDeleteCommand DataAdapter Command Connection sp_UPDATEsp_INSERTsp_DELETE Database DataSet DataReader

30 Generating a Dataset You can generate a dataset… You can generate a dataset… …through the UI… …through the UI… Creates a dataset that allows you to access data as an object Creates a dataset that allows you to access data as an object …or through code… …or through code… …and then fill the DataSet from the DataAdapter(s) …and then fill the DataSet from the DataAdapter(s) DataSet ds = New DataSet() DataAdapter1.Fill(ds)DataAdapter2.Fill(ds)DataAdapter1.Fill(ds)DataAdapter2.Fill(ds)

31 Displaying DataSet Data in List-Bound Controls Set the properties Set the properties Fill the DataSet, then call the DataBind method Fill the DataSet, then call the DataBind method DataAdapter1.Fill(ds)lstEmployees.DataBind()DataAdapter1.Fill(ds)lstEmployees.DataBind()PropertyPropertyDescriptionDescription DataSource  The DataSet containing the data DataMember  The DataTable in the DataSet DataTextField  The field in the DataTable that is displayed DataValueField  The field in the DataTable that becomes the value of the selected item in the list

32 Updating Data 1/3 Using the DataGrid property builder add the Edit, Update, Cencle Buttons/Links

33 Updating Data 2/3 Click on the Events button (mark with red circle) and duble click inside the Cancel Command. You will see DataGrid1_CancelCommand. Do the same for EditCommand and UpdateCommand void DataGrid1_CancelCommand(object sender, DataGridCommandEventArgs e) { } void DataGrid1_EditCommand(object sender, DataGridCommandEventArgs e) { } void DataGrid1_UpdateCommand(object sender, DataGridCommandEventArgs e) { }

34 Updating Data 3/3 Click on the Events button (mark with red circle) and duble click inside the Cancel Command. You will see DataGrid1_CancelCommand. Do the same for EditCommand and UpdateCommand void DataGrid1_CancelCommand(object sender, DataGridCommandEventArgs e) { } void DataGrid1_EditCommand(object sender, DataGridCommandEventArgs e) { } void DataGrid1_UpdateCommand(object sender, DataGridCommandEventArgs e) { }

35 Updating Data 4/3 Click on the Events button (mark with red circle) and duble click inside the Cancel Command. You will see DataGrid1_CancelCommand. Do the same for EditCommand and UpdateCommand void DataGrid1_CancelCommand(object sender, DataGridCommandEventArgs e) { } void DataGrid1_EditCommand(object sender, DataGridCommandEventArgs e) { } void DataGrid1_UpdateCommand(object sender, DataGridCommandEventArgs e) { }

36 Using Datasets vs. DataReaders Open conversation Open conversation

37 Creating a Microsoft ASP.NET Web Application Requirements of a Web Application Requirements of a Web Application Sharing Information Between Pages Sharing Information Between Pages Securing an ASP.NET Application Securing an ASP.NET Application Page Output Caching Page Output Caching Application Caching Application Caching Demo Samples Demo Samples

38 Project 2 0f 3 Building Dynamic Web Application Building Dynamic Web Application

39 What Next? Web Services


Download ppt "ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC."

Similar presentations


Ads by Google