0% found this document useful (0 votes)
30 views

Pre-Assessment Questions: State Management and Accessibility

The document discusses state management in ASP.NET applications. It describes client-side state management options like view state, hidden fields, cookies, and query strings. It also covers server-side options like application state, session state, and database support. The document provides advantages and limitations of each state management option.

Uploaded by

ajay_anav
Copyright
© © All Rights Reserved
Available Formats
Download as PPS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Pre-Assessment Questions: State Management and Accessibility

The document discusses state management in ASP.NET applications. It describes client-side state management options like view state, hidden fields, cookies, and query strings. It also covers server-side options like application state, session state, and database support. The document provides advantages and limitations of each state management option.

Uploaded by

ajay_anav
Copyright
© © All Rights Reserved
Available Formats
Download as PPS, PDF, TXT or read online on Scribd
You are on page 1/ 35

State Management and Accessibility

Pre-Assessment Questions
1. Errors in _____________ file causes configuration errors.

a. Web.config
b. AssemblyInfo.cs
c. Global.asax
d. WebForm1.aspx

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 1 of 35


State Management and Accessibility

Pre-Assessment Questions (Contd.)


2. Which of the following includes the Null reference error?
a. Configuration error
b. Runtime error
c. Compilation error
d. Parser error

3. Which one of the following files include the Application Error event?
a. Web.config
b. AssemblyInfo.cs
c. Global.asax
d. WebForm1.aspx

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 2 of 35


State Management and Accessibility

Pre-Assessment Questions (Contd.)


4. Custom errors are configured within the customErrors section of the
________________ file.
a. AssemblyInfo.cs  
b. Web.config
c. Global.asax
d. WebForm1.aspx

5. Which of the following is a property of the EventLog class?


a. Source
b. URL
c. Path
d. Number

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 3 of 35


State Management and Accessibility

Solutions to Pre–Assessment
Questions
1. a. Web.config
2. a. Configuration error
3. c. Global.asax
4. b. Web.config
5. a. Source

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 4 of 35


State Management and Accessibility

Objectives
In this lesson, you will learn to:
• Implement state management using client side options
• Implement state management using server side options
• Implement accessibility in ASP.NET application
• Identify accessibility design guidelines for the Web

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 5 of 35


State Management and Accessibility

Understanding State Management


• State management options can be divided into two categories:
• Client-state management
• Server-state management

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 6 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• The following table summarizes client-side and server-side options:

Client-side options Server-side options

View state property Application state

Hidden Fields Session state


Cookies Database support
Query strings

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 7 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• Client-side state management options involve storing information either in a
Web page or on a client computer.
• Client-side state management options are:
• View State
• Dissent Fields
• The ViewState property of an ASP.NET Web page enables you to retain page
and control-specific values between round trips.
• ASP.NET Framework uses the ViewState property to automatically save
the values of the Web page and each control on the Web page prior to
rendering the page.
• The view state of a Web page or a control consists of the cumulative
property values of the page or the control.
• By default, the ViewState property of both Web page and the controls on
the Web page is enabled.
©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 8 of 35
State Management and Accessibility

Understanding State Management


(Contd.)
• The various advantages of using view state are:
• The values in view state are stored in a standard HTML format as part of a
Web page. Therefore, no Web server resource is required to maintain it.
• The view state can be easily implemented in the ASP.NET Web page by
setting the EnableViewState property of a Web page and server controls.
• The values in view state are hashed, compressed, and encoded for Unicode
implementations. Therefore, values in view state are more secured than
values stored in general hidden form fields.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 9 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• The various limitations of view state option are:
• Storing large values can cause a page to slow down when users display it or
post it
• View state is stored in a hidden field in a page

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 10 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• In ASP.NET, you can use the HTML-standard hidden fields in a Web form to
store page-specific information.
• A hidden field does not render in a Web browser.
• Some of the advantages of using hidden form fields are:
• The hidden form field can store page-specific information without accessing
any Web server or Web browser resource.
• The hidden form field can be easily implemented in an ASP.NET Web form
page by adding the HtmlInputHidden control to a Web page and using the
Value property of the control.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 11 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• Some of the limitations of hidden form fields are :
• You can view the information stored in the hidden field by accessing the
page output source. Therefore, the values stored in hidden form fields are
not very secure.
• The hidden form field does not support more than a single value field to
store information.
• The hidden form fields are stored in a page. Therefore, storing large values
in hidden form fields can slow down the processing of the page.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 12 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• A cookie is used to store small piece of information on client machine.
• A cookie contains page-specific information that a Web server sends to a client
along with page output.
• The advantages of using cookies are:
• Cookie is stored on the client computer and can be read by the server after
a request for a page is posted. Therefore, no server resource is involved in
maintaining the cookie.
• Cookie is a text-based data structure that contains key-value pairs.
Therefore, it is easy to create and manipulate cookies.
• Cookie can either expire when the browser session ends or exist indefinitely
on the client computer, subject to the expiration rules on the client.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 13 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• Following are the limitations of the cookies:
• Cookies that are stored on client computers have a limited size.
• Users can disable cookies to prevent them from being stored on the hard
disk of their computer. If a user denies permission for cookies, an ASP.NET
Web application cannot store cookies on the client computer.
• Users can tamper with cookies because cookies are stored on the client
computer.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 14 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• If you need to submit information back to a Web page or another page by using
a URL, you can use a query string. A query string provides a simple way to pass
information from one page to another.
• The query string is part of the request that appears after the Question mark (?)
character in the URL.
• Following are the advantages of query string are:
• A query string is contained in the HTTP request for a specific URL.
Therefore, no server resource is involved to process a query string.
• Many Web browsers support passing values in a query string. Therefore, if
you create a Web application that passes information from one page to
another using a query string, it will be processed in most of the browsers.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 15 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• Following are the limitations of a query string:
• The information in a query string is directly visible to the user in the
browser window.
• There is a limit to the amount of information that you can pass from one
page to another using query strings

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 16 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• Server-side state management options helps you manage application and
session-related information. Server-side options store information on the Web
server.
• These options are as follows:
• Application state
• Session state
• Application state is created when each browser request is made for a specific
URL.
• All information stored in the application state is shared among all the pages
of the Web application by using the HttpApplicationState class.
• Variables and objects added to the application state are global to an
ASP.NET application.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 17 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• After an object is added to an application state, it remains in the application
state until the application is shut down, the Global.asax file is modified, or
the item is explicitly removed from the application state.
• To handle the problems of simultaneous access of application state values,
the HttpApplicationState class provides two methods, Lock() and
Unlock(). These methods allow only one thread at a time to access
application state variables and objects.
• Following are the advantages of using application state options :
•Application state is easy to use and is consistent with other .NET
Framework classes.
•Storing information in application state involves maintaining only a single
copy of the information.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 18 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• Following are the limitations of using application state options:
• The data stored in an application state is lost when the Web server
containing the application state fails due to a server crash, upgrade, or
shutdown.
• Application state requires server memory and can affect the performance of
the server and the scalability of the Web application.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 19 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• Session state is used to store session-specific information for a Website.
• the scope of session state is limited to the current browser session.
• The built-in session state feature automatically performs the following actions:
• Identify and classify requests coming from a browser into a logical
application session on the server.
• Store session-specific data on the server for use across multiple browser
requests.
• Raise session lifetime-related events, such as Session_OnStart and
Session_OnEnd, which can be handled using application code.
• Automatically release session data if a browser does not access an
application within a specified timeout period.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 20 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• Following are the advantages of using session state option:
• Session state is event-driven.
• Data in session state variables and objects can survive Web server restarts
without losing session data
• Session state can be used in both multi-computer and multi-process
configurations.
• A session state facility can work with browsers that do not support HTTP
cookies.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 21 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• Following is the limitation of using session state options:
• Session state variables are stored in memory until they are either removed
or replaced. This can degrade Web server performance.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 22 of 35


State Management and Accessibility

Understanding State Management


(Contd.)
• In addition to client-side and server-side options, ASP.NET also provides
database support to maintain state on your Web site. It is used to store user-
specific information where the information store is large.
• Some of the advantages that a database offers to state management are:
• Security
• Consistency
• Personalization
• Using a database for state management in an ASP.NET application can be
disadvantageous because of the following reasons:
• Database support in state management involves complex hardware and
software configurations.
• The performance of a Web site may go down

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 23 of 35


State Management and Accessibility

Sending Email from an Asp.Net page


• Problem Statement
• The New User registration Web application needs to automatically
save a cookie by the name E-Shoppe on the client computer when
a user successfully registers with the E-Shoppe site. The cookie
should be a persistent cookie having the expiry date 12/12/2005.
The application should also send an e-mail message confirming
new user registration for the E-Shoppe site. The subject of the
confirmation message should be “Thanks for registering” and the
body of the message should be “Thank you for registering with
the E-Shoppe site”. The e-mail message should be in an HTML
format and should be sent when all the required fields of the new
registration form have been validated. A blind carbon copy (Bcc)
of the e-mail message should also be sent to the Business Group
Head of the E-Shoppe site. The e-mail address of the Business
Group Head is [email protected].

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 24 of 35


State Management and Accessibility

Sending Email from an Asp.Net page


(Contd.)
• Solution
1. Identify the data that needs to be stored on the client computer.
2. Identify the data that needs to be sent by using e-mail message.
3. Identify the mechanism to write cookie on client computers.
4. Identify the mechanism to send an e-mail message from an ASP.NET
page.
5. Perform appropriate steps to enable the application to write cookies
on the client computer.
6. Write the code to send the e-mail message.
7. Run the application.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 25 of 35


State Management and Accessibility

Implementing Accessibility in ASP.NET


Application
• Incorporating accessibility guidelines make applications more pleasing and
user friendly. Accessibility is a concept that is applicable to every
application regardless of the technology and platform on which the
application is developed.
• Accessibility refers to the degree of ease with which the application can be
used by variety of people.
• Five basic principles that every accessible design should follow:
• Flexible user interface
• Flexible input features
• Three-click rule
• Flexible output features
• Consistent interface

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 26 of 35


State Management and Accessibility

Implementing Accessibility in ASP.NET


Application (Contd.)
• Accessibility makes an application user friendly.
• Accessibility guidelines can be divided into three categories. These categories
are:
• Guidelines for navigation styles
• Guidelines for using graphics
• Guidelines for form layout

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 27 of 35


State Management and Accessibility

Implementing Accessibility in ASP.NET


Application (Contd.)
• Some of the guidelines for navigation styles are:
• Support keyboard navigation
• Standardize image maps
• Use meaningful text links

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 28 of 35


State Management and Accessibility

Implementing Accessibility in ASP.NET


Application (Contd.)
• Some of the guidelines for using graphics are:
• Use alternate text for every image
• Proper Image size

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 29 of 35


State Management and Accessibility

Implementing Accessibility in ASP.NET


Application (Contd.)
• Some of the guidelines for form layout are:
• Minimize the use of style sheets
• Proper use of frames
• Proper use of controls

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 30 of 35


State Management and Accessibility

Creating Web Application using


Accessibility
• Problem Statement
• The Galaxy Cineplex is launching its online Web site. The purpose
of this Web site is to provide information about different movies
that are currently playing. Mark Weber, an employee of Mirage
solution is assigned the task of developing the site. The site will
have one main web form, which will contain all the movies
currently playing. User can click on any of the movie for more
information about the movie. All the accessibility guidelines have
been followed while developing this Site.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 31 of 35


State Management and Accessibility

Creating Web Application using


Accessibility (Contd.)

• Solution
1. Create an ASP.NET Web application.
2. Design a WelcomePage form.
3. Add the Functionality to the WelcomePage Form.
4. Run the program.
5. Perform accessibility testing.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 32 of 35


State Management and Accessibility

Summary
• In this lesson, you learned:
• State management is the process by which you maintain application and
session-related information when multiple users request for the same or
different pages of an ASP.NET application.
• State management also includes maintaining page-level information during the
round trip of a Web Form page.
• In an ASP.NET application, the state management feature is implemented using
client-side options and server-side options.
• Client-side options include:
• View State property
• Hidden Fields
• Cookies
• Query Strings

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 33 of 35


State Management and Accessibility

Summary (Contd.)
• Server-side options include:
• Application state
• Session state
• Database support
• ASP.NET Framework uses the ViewState property to automatically save
the values of the page and of each control before the page is rendered.
• A cookie is a small data structure used by a Web server to deliver data to
a Web client. A cookie contains page-specific information that a Web
server sends to a client along with page output.
• Cookies are saved on the client computer and can be either temporary or
persistent.
• A temporary cookie is stored in the volatile memory of the client
computer, whereas a persistent cookie is stored in a text file on the hard
disk of the client computer.

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 34 of 35


State Management and Accessibility

Summary (Contd.)
• ASP.NET provides application state as a means of storing global
application-specific information.
• Accessibility is a concept that is applicable to every application regardless
of the technology and platform on which the application is developed.
• There are four basic principles that every accessible design should follow.
They are:
• Flexible user interface
• Flexible input features
• Flexible output features
• Consistent interface

©NIIT Developing Web Applications Using ASP.NET Lesson 4A / Slide 35 of 35

You might also like