ASP.NET Session 5

Post on 20-Jun-2015

125 views 1 download

Tags:

transcript

Creating ASP.NET Web Form

Session 5

Objectives

• Learn how to create Web Form in .NET Platform using Visual Studio.

• ASP.NET Page lifecycle.

Introduction

• What is a Web Form?

Ans:-

A web form on a web page allows a user to enter data that is sent to a server for processing. And Server process the web page & send HTML stream to the client.

Steps to create ASP.NETWeb Form

• To create a Web form in ASP.NET we need the Visual Studio.Net.

• Under the ‘File’ menu we need to click on New-Web Site or we can simply press Shift+Alt+N from the keyboard.

• A new window will appear. The name of the window will be ‘New Web Site’. It will look like this…

Steps to create a ASP.NETWeb Form(Contd.)

• If we press on ‘Ok’ the ‘Default.aspx” window will generate where the HTML code will be written.

• It calls the ‘Code-behind’.

• It will be look like this…

Steps to create ASP.NETWeb Form(Contd.)

• After that we have to put the mouse pointer over the Solution Explore.

• On the Solution Explorer we need to double click on ‘Default.aspx.cs’ option under the ‘Default.aspx’.

• It will open the C# devolvement window. Here we can write the C# coding for the Web site.

• It calls the ‘Code inline’.

Steps to create ASP.NETWeb Form(Contd.)

• Now we need to design our Web site.

• For that we need to go to ‘Designer’ pane.

• It may be find on the Solution Explore.

• Using the dedicated Toolbox option we can add numerous controls on the ‘Design’ pane.

Steps to create ASP.NETWeb Form(Contd.)

• Let us create the simple ‘Hello World’ programming for our first ASP.NET Web form.

• On that program we will understand what we can do on the ‘Design’ pane.

• The first page will show us the ‘Hello World’ message on the web browser without any controls.

• It will be like this…

Steps to create ASP.NET Web Form(Contd.)

• The code for the web form will be…

• Now we will format the output on the ‘Design’ window using a simple control- Label control.

• It will look like this…..

Steps to create ASP.NET Web Form(Contd.)

• The code for the web form will be…

Sequence of ASP.NET events

1)Page Init

2)Page Load

3)Controls Events

4)Page Unload events

Page Init events only occurs when 1st time the page is started, But Page Load occurs in subsequent request of the page.

** Page Load event guarantees that all controls are fully loaded.

Summary

• Web Page Created.• Steps of web page creation.