Unit 1 - Framework & Web Contents
Unit 1 - Framework & Web Contents
Unit 1 - Framework & Web Contents
Web Contents
UNIT - 1
Overview ASP.NET
Framework
ASP.NET is an open source server-side Web application
framework designed for Web development to produce dynamic Web
pages.
It was developed by Microsoft to allow programmers to build
dynamic web sites, web applications and web services.
It was first released in January 2002 with version 1.0 of the.NET
Framework, and is the successor to Microsoft's Active Server Pages
(ASP) technology.
ASP.NET is built on the Common Language Runtime (CLR), allowing
programmers to write ASP.NET code using any supported .NET
languages like VB.NET and C#.
The Microsoft .NET Platform provides all of the tools and technologies
that are needed to build distributed Web applications.
Overview ASP.NET
Framework
ASP.NET is integrated with Visual Studio .NET, which
provides a GUI designer, a rich toolbox, and a fully
integrated debugger.
In ASP.NET, you can write the HTML code in the .aspx file
and the code for programming logic in the code-behind file
(.aspx.vb or .aspx.cs ). Also ASP.NET introduces two sets of
controls, the HTML controls and the Web controls, which
are collectively known as "server controls."
ASP.NET incorporates all the important standards of our
time, such as XML and SOAP, plus with ADO.NET and the
foundation class libraries.
Overview ASP.NET
Framework
ASP.NET is great for building standards-based
websites with HTML5, CSS3, and JavaScript.
ASP.NET supports three approaches for making web
sites.
ASP.NET Web Forms uses controls and an event-model
for component-based development.
ASP.NET MVC values separation of concerns and
enables easier test-driven development.
ASP.NET Web Pages prefers a single page model that
mixes code and HTML markup.
ASP.NET Versions
ASP.NET Benifits
Advantages:
All data stored at server
Due to thin Client application less load on client.
Easy to Implement Security.
Disadvantages:
Clients are dependent on servers.
All load transfer on Servers.
Better bandwidth is required for server.
ASP.NET Execution
.ascx : These are ASP.NET user controls. User controls are similar to
web pages, except that they can’t be accessed directly. Instead, they
must be hosted inside an ASP.NET web page. User controls allow you
to develop a small piece of user interface and reuse it in as many web
forms as you want without repetitive code.
Rich Controls : The rich controls enable you to render things such as
calendars, file upload buttons, rotating banner advertisements, and
multi-step wizards.
Types of Controls in ASP.NET
Data Controls : The data controls enable you to work with data such
as database data. For example, you can use these controls to submit
new records to a database table or display a list of database records.
Navigation Controls :The navigation controls enable you to display
standard navigation elements such as menus, tree views, and bread
crumb trails.
Login Controls : The login controls enable you to display login,
change password, and registration forms.
Web Part Controls : The Web Part controls enable you to build
personalizable portal applications.
PreInit
Init
InitComplete
LoadViewState
LoadPostData
PreLoad
Load
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
UnLoad
Control Class
Property Description
When set to true (the default), the page isn’t sent to the client
BufferOutput until it’s completely rendered and ready, as opposed to being
sent piecemeal.
References an HttpCachePolicy object that allows you to
Cache
configure how this page will be cached
Cookies The collection of cookies sent with the response.
Write(), These methods allow you to write text or binary content directly
BinaryWrite(), to the response stream. You can even write the contents of a file.
and These methods are de-emphasized in ASP.NET and shouldn’t be
WriteFile() used in conjunction with server controls.
This method transfers the user to another page in your
Redirect()
application or a different website.
Introduction to standard
Controls
Web Forms are the basics of building ASP.NET based web
sites.
Web site is collection of number of web Forms / pages
where each Web Form contains number of Web Server
controls.
Which are described as further:
Button control
Button control is used to submit the data to the server. Button
control works like a Push Button when you click the data is
submitted to the server.
Property Description
AccessKey Enables you to specify a key that navigates to the Button control.
CommandArg Enables you to specify a command argument that is passed to the Command
ument event.
CommandNa Enables you to specify a command name that is passed to the Command
me event.
Example:
<asp:Button ID="Button2" runat="server" Text="Button"
onclick="Button2_Click" />
TextBox Control
TabIndex Enables you to specify the tab order of the text box.
Wrap Enables you to specify whether text word-wraps when the
TextMode is set to Multiline.
CheckBox
AutoPostBack Enables you to post the form containing the CheckBox back to the
server automatically when the CheckBox is checked or unchecked.
TabIndex Enables you to specify the tab order of the check box.
TextAlign Enables you to align the label for the check box. Possible values
are Left and Right.
Label
BorderColor Enables you to set the color of a border rendered around the
label.
BorderWidth Enables you to set the size of a border rendered around the
label.
Property Descrition
DefaultButton Enables you to specify the default button in a Panel. The
default button is invoked when you press the Enter button.
SelectedIndex Gets or Sets the index of the selected item in the dropdown box.
DataValueField Name of the data source field to supply the value of the items.
AutoPostBack true or false. If true, the form is automatically posted back to the server
when user changes the dropdown list selection. It will also
fireOnSelectedIndexChanged method.
AppendDataBoundIte true or false. If true, the statically added item (added from .aspx page) is
ms maintained when adding items dynamically (from code behind file) or items
are cleared.
OnSelectedIndexCha Method name that fires when user changes the selection of the dropdown
nged box. (Fires only when AutoPostBack=true.)
ListBox
All properties and its working resembles DropDownList box.
However, ListBox has two extra properties
called Rows and SelectionMode. ListBox control is used to give a
single or multiple select option to the user (based on the property
set) from multiple listed items. You can specify its height and width
in pixel by setting its height and width but you will not be able give
mutliple select option to the user. When it is rendered on the page,
it is implemented through <select/> HTML tag. It is also called as
Combo box.
Its properties like BackColor, ForeColor etc. are implemented
through style properites of <span>. It has less property to decorate
in comparison with other controls. There is no property
like BorderStyle, BorderWidth. in DropDownList control.
You can add its option items by directly writing into .aspx page
directly or dynamically add at run time or bind through database.
Property Description
Rows No. of rows (items) can be set to display in the List.
SelectionMode Single or Multiple. If multiple, it allows user to select multiple items from the
list by holding Ctrl or Shift key.
SelectedValue Get the value of the Selected item from the dropdown box.
SelectedIndex Gets or Sets the index of the selected item in the dropdown box.
SelectedItem Gets the selected item from the list.
Items Gets the collection of items from the dropdown box.
DataTextField Name of the data source field to supply the text of the items.
DataValueField Name of the data source field to supply the value of the items.
DataSourceID ID of the datasource component to provide data.
DataSource The datasource that populates the items in the listbox box.
AutoPostBack true or false. If true, the form is automatically posted back to the server when
user changes the dropdown list selection. It will also
fireOnSelectedIndexChanged method.
OnSelectedIndexC Method name that fires when user changes the selection of the dropdown box.
hanged (Fires only when AutoPostBack=true.)
FileUpload
The FileUpload control allows the user to browse for and select the
file to be uploaded, providing a Browse button and a text box for
entering the filename.
Once, the user has entered the filename in the text box, by typing
the name or browsing, the SaveAs method of the FileUpload
control can be called to save the file to the disk.
The basic syntax for using the FileUpload is:
<asp:FileUpload ID= "Uploader" runat = "server" />
The FileUpload class is derived from the WebControl class, and
inherits all its members. Apart from those, the FileUpload class has
the following read-only properties:
Property Description