ASP NET BASE CLASS LIBRARY NET Framework Class
ASP. NET
BASE CLASS LIBRARY. NET Framework Class Library is the collection of classes, namespaces, interfaces and value types that are used for. NET applications.
CLR. NET CLR is a run-time environment that manages and executes the code written in any. NET programming language. It converts code into native code which further can be executed by the CPU.
STRUCTURE
FUNCTIONS: Ø It converts program into native code. Ø Handles Exceptions Ø Provides type safety Ø Memory management Ø Provides security Ø Improved performance Ø Language independent Ø Platform independent Ø Garbage collection
CTS The Common Type System (CTS) is a standard for defining and using data types in the. NETframework. CTS defines a collection of data types, which are used and managed by the run time to facilitate cross-language integration. In contrast to low-level languages like C and C++ where classes/structs have to be used for defining types often used (like date or time), CTS provides a rich hierarchy of such types without the need for any inclusion of header files or libraries in the code.
CTS is a specification created by Microsoft and included in the European Computer Manufacturer‘s Association standard. CTS is designed as a singly rooted object hierarchy with System. Object as the base type from which all other types are derived. CTS supports two different kinds of types: Ø Value Types: Contain the values that need to be stored directly on the stack or allocated inline in a structure. Ø Reference Types: Store a reference to the value‘s memory address and are allocated on the heap.
NAMESPACES A namespace is a declarative region that provides a scope to the identifiers (the names of types, functions, variables, etc) inside it. Namespaces Description System It includes all common datatypes, string values, arrays and methods for data conversion. System. IO, System. Directory. Services, System. IO. Isolated. Storage These are used to access, read and write files.
Namespaces Description System. Net, System. Net. Sockets These are used to communicate over the Internet when creating peer-to-peer applications. System. Windows. Forms, System. Windows. Forms. Design These namespaces are used to create Windows-based applications using Windows user interface components. System. Diagnostics It is used to debug and trace the execution of an application.
INTERMEDIATE CODE Ø Ø Ø Intermediate language (IL) is an object-oriented programming language designed to be used by compilers for the. NET Framework before static or dynamic compilation to machine code. The IL is used by the. NET Framework to generate machine-independent code as the output of compilation of the source code written in any. NET programming language. This term is also known as Microsoft intermediate language (MSIL) or common intermediate language (CIL).
With the help of a suitable just-in-time (JIT) compiler, IL code can be executed on any computer architecture supported by the JIT compiler. JIT compilation provides better performance, preserves memory, and saves time during application initialization. The two tools associated with IL code are the MSIL Assembler (Ilasm. exe) and the MSIL Disassembler (Ildasm. exe). The former(MSIL Assembler) generates a portable executable file from IL code and permits viewing the IL code in human-readable format.
The latter(MSIL Disassembler) converts a portable executable file back to a text file, for viewing and modification. Both are automatically installed as part of Visual Studio.
VALIDATION CONTROLS ASP. NET validation controls validate the user input data to ensure that useless, unauthenticated, or contradictory data don't get stored. ASP. NET provides the following validation controls: Required. Field. Validator Range. Validator Compare. Validator Regular. Expression. Validator Custom. Validator Validation. Summary
REQUIRED FIELD VALIDATOR The Required. Field. Validator control ensures that the required field is not empty. It is generally tied to a text box to force input into the text box. SYNTAX: <asp: Required. Field. Validator ID="rfvcandidate" runat="server" Control. To. Validate ="ddlcandidate" Error. Message="Please choose a candidate" Initial. Value="Please choose a candidate"> </asp: Required. Field. Validator>
RANGEVALIDATOR CONTROL The Range. Validator control verifies that the input value falls within a predetermined range. It has three specific properties: Properties Description Type It defines the type of the data. The available values are: Currency, Date, Double, Integer, and String. Minimum. Value It specifies the minimum value of the range. Maximum. Value It specifies the maximum value of the range.
COMPAREVALIDATOR CONTROL The Compare. Validator control compares a value in one control with a fixed value or a value in another control. It has the following specific properties: Properties Description Type It specifies the data type. Control. To. Compare It specifies the value of the input control to compare with. Value. To. Compare It specifies the constant value to compare with. Operator It specifies the comparison operator, the available values are: Equal, Not. Equal, Greater. Than, Greater. Than. Equal, Less. Than. Equal, and Data. Type. Check.
REGULAREXPRESSIONVALIDATOR The Regular. Expression. Validator allows validating the input text by matching against a pattern of a regular expression. The regular expression is set in the Validation. Expression property. The following table summarizes the commonly used syntax constructs for regular expressions:
Character Escapes Description b Matches a backspace. t Matches a tab. r Matches a carriage return. v Matches a vertical tab. f Matches a form feed. n Matches a new line. Escape character.
Apart from single character match, a class of characters could be specified that can be matched, called the metacharacters. Metacharacters Description . Matches any character except n. [abcd] Matches any character in the set. [^abcd] Excludes any character in the set. [2 -7 a-m. A-M] Matches any character specified in the range. w Matches any alphanumeric character and underscore. W Matches any non-word character. s Matches whitespace characters like, space, tab, new line etc. S Matches any non-whitespace character. d Matches any decimal character. D Matches any non-decimal character.
Quantifiers could be added to specify number of times a character could appear. Quantifier Description * Zero or more matches. + One or more matches. ? Zero or one matches. {N} N matches. {N, } N or more matches. {N, M} Between N and M matches.
CUSTOM VALIDATOR The Custom. Validator control allows writing application specific custom validation routines for both the client side and the server side validation. The client side validation routine should be written in a scripting language, such as Java. Script or VBScript, which the browser can understand. The server side validation routine must be called from the control's Server. Validate event handler. The server side validation routine should be written in any. Net language, like C# or VB. Net.
VALIDATION SUMMARY The Validation. Summary control does not perform any validation but shows a summary of all errors in the page. The summary displays the values of the Error. Message property of all validation controls that failed validation. The following two mutually inclusive properties list out the error message: Show. Summary : shows the error messages in specified format. Show. Message. Box : shows the error messages in a separate window.
VIEW STATE State management means to preserve state of a control, web page, object/data, and user in the application explicitly because all ASP. NET web applications are stateless, i. e. , by default, for each page posted to the server, the state of controls is lost.
View state is the page-level state management technique used in the ASP. NET page framework to retain the value of controls and page between round trips. Data objects such as hash tables, strings, array objects, array list objects, Boolean values and custom-type converters can be stored in view state. View state is ideally used when the data to be preserved is relatively small and the data need not be secured
By default, the view state is switched on and regardless of whether used during a postback, it serializes the information in every control found on the page. To disable the view state for a single control, the Enable. View. State property needs to be set as false. The attribute Enable. View. State. Mac is provided to detect any corruption attempt or technique on the view state.
q Advantage: § q The mean features of view state are to store the values of control properties and pages found in the concerned page, without the help of a session, preserve the value of the control after the postback operation and to create a custom view state provider for storing view state information in a database. Disadvantages: For large amounts of data, the performance is not optimal, as large values could potentially cause view state to be slow View state can only store values for same page only.
WEB CONTROLS Webcontrol class: § Serves as the base class that defines the methods, properties and events common to all controls in the System. Web. UI. Web. Controls namespace. § Some of the properties are mentioned below : PROPERTY DESCRIPTION Back. Color Gets or sets the background color of the Web server control. Border. Color Gets or sets the border color of the Web control. Fore. Color Gets or sets the foreground color (typically the color of the text) of the Web server control. Enabled Gets or sets a value indicating whether the Web server control is enabled.
PROPERTY DESCRIPTION ID Gets or sets the programmatic identifier assigned to the server control. View. State Gets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page. Tooltip Gets or sets the text displayed when the mouse pointer hovers over the Web server control.
INPUT CONTROL Input controls let the user enter text data into the application. ASP. NET supports only one input web control: the Text. Box. The Text. Box behaves like a singleline or multiline edit control, depending on the value of its Text. Mode property.
DISPLAY CONTROLS Display controls simply render text or images to the browser. Control Purpose Image Displays the image specified in the control's Image. Url property. Label Displays the text specified in the control's Text property. Panel Groups a set of controls (like a Frame control in Windows). Table Displays a table of information. This control has two collections: Table. Rows, which contains the rows, and Table. Cells, which contains the columns in a row.
ACTION CONTROLS Action controls allow users to perform some action on that page, such as navigating to a different URL, submitting a form, resetting a form's values, or executing a client script. Control Purpose Button Displays a command button that posts a form to the server when clicked. Image. Button Displays an image that posts a form to the server when clicked. Link. Button Displays a hyperlink text that posts a form to the server when clicked. Hyperlink Displays a hyperlink text that navigates from one page to another when clicked.
SELECTION CONTROLS Selection controls allow the user to select one or more values from a list. They include both the Check. Box and Radio. Button controls, which are designed to work in a group. Control Purpose Check. Box Selects or unselects an option. You can toggle the selection. Radio. Button Selects only one option out of a group. You can unselect an option only by selecting another Radio. Button control in the group. List. Box Allows the user to select one or more options from a list represented by List. Item controls. This control always occupies a fixed space in the form.
Control Purpose Drop. Down. List Allows the user to select only one option out of a list represented by List. Item controls. This control is used where the space in the form is limited. Radio. Button. List Presents a list of radio buttons represented by List. Item controls and allows selection of only one option. Check. Box. List Presents a list of checkboxes represented by List. Item controls and allows you to select zero or more of the options.
THANK YOU
- Slides: 34