Академический Документы
Профессиональный Документы
Культура Документы
Module Overview
Overview of the Structure of a Web Application Controlling View State
App_Code
App_WebReferences
Bin
Global.asax
Application is compiled the first time a user requests a resource from the website.
One assembly for each directory, including root directory. If there are files in more than one programming language, there will be one assembly per folder and language.
Dynamic compilation
After the first compilation, the files are cached. Any change to the source files will trigger a recompilation of the application. The compiled files are placed in the following location:
%SystemRoot%\Microsoft.NET\Framework\versionNumber\Temporary ASP.NET Files
Using ViewStateMode
Using Control State View State Best Practices
Page and controls property values between postbacks Values between postbacks without storing them in session state or user profile
Performance Implications:
By using the view state, the ASP.NET infrastructure can recreate
the state of the page when it is posted back, so the users get the feel of running a stateful application considerably
Using ViewStateMode
If you set EnableViewState to false, view state will be
turned off for the page/control and all their child controls controlled by ViewStateMode:
If EnableViewState is set to true, view state behavior is Enable The Page/Control is using view state Disable The Page/Control has its view state turned off
Inherit(Default) The control inherits the view state of the parent control
necessary
control state.
the view state, or move it to the end of the page functioning of the control
What is Localization?
Globalization Process of designing and developing an
application that supports localized user interfaces and regional data for users in multiple cultures application is ready for localization
resources into localized versions for each culture that the application will support
Local resources
Reside in App_LocalResources One resource file per ASP.NET file and language
Global resources
Implicit localization Any control that has an attribute called meta:resourcekey set will read the values for the properties that are Localizable from the local resource file
Localizable is a design attribute which is set by the designer of the control to mark it as localizable
Explicit localization By using expressions that reads the data from a local or a global resource file
Client side:
Application state
Session state
User profile Caching
Posted data
Cookies Query String
Except for InProc, all other modes require the data saved
To use the database, configure your website as follows: <configuration> <system.web> <sessionState mode="SQLServer" sqlConnectionString="Integrated Security=SSPI; data source=SampleSqlServer;" /> </system.web> </configuration>
Why Validate?
Validation should be a requirement in all applications, to provide:
Security, to protect against injection attacks Correctness, to ensure that the data is valid and business
the server
Validation Controls
ASP.NET has a set of predefined validation controls
Validation Groups
Validation groups allow you to organize validation controls
on a page as a set
property to the same value for all controls that belongs to the same group validation group, then a value of IsValid will be determined based only on the validity of the controls belonging to that group
Inline Displays the message next to the control that contains the invalid input Summary Displays the message in a ValidationSummary control Inline and Summary Provides combination of the Inline and Summary options Custom Allows you to write script or custom code when an error is not in the norm (for example, to check for certain values); uses the Page.IsValid property to determine whether an error has occurred
Custom Validation
If none of the existing controls can be used to validate a
certain type of data, you can use your own validation logic with the CustomValidator control. properties of interest:
Localized Content
Exercise 2: Persisting data on Web Forms Pages Exercise 3: Utilizing View State Effectively Exercise 4: Adding Validation to Web Forms Pages
Logon information
Lab Scenario
Lab Review
Why did you use mainly local resources for localizing the
Web Forms page and the Site.Master master page? Session state? view state?
Why and when would you use SQL Server as storage for What did you notice about the effects of turning on and off
Best Practices