Asp. NET hands-on Tutorials (1)

Source: Internet
Author: User
Tags definition exception handling functions garbage collection net tostring access visual studio

First, start

1. Introduction

Welcome to ASP.net's immediate hands-on tutorial.

Asp. NET hands-on tutorials are made up of a series of examples and support explanations designed to give developers a quick understanding of the ASP.net syntax, framework, and powerful features of the ASP.net Network application framework. All instances of the design are short and easy to understand, and can fully demonstrate the corresponding functions of asp.net. After completing this tutorial, you should be familiar with the following:

· Asp. NET syntax. Of course, for skilled ASP developers, some asp.net syntax elements are familiar, while others are unique to the new framework. The examples in this tutorial cover the details of all the syntactic elements.

· Asp. NET structure and features. This tutorial describes the features of ASP.net, which allow developers to create interactive, world-class applications at an unprecedented rate of efficiency.

• Best practices. Examples of this tutorial demonstrate the best way to ASP.net functionality while avoiding potential pitfalls.

The reader object level of this textbook requires:

If you've never had the experience of developing a Web page before, then this textbook is not for you. You should be familiar with HTML and general Web development terminology. You don't need to have an ASP experience, but you should be familiar with the concept of interactive pages, including forms, scripts, and data access.

Examples of digestion and absorption of this textbook

This textbook is the best practice for the content presented. Each instance is based on the definition of concept and the extension of the previous example. The example is a complete series from simple to complex, from single technology to application

2, what is asp.net

ASP.net is an application framework built on the common language Runtime Library (CLR). He used to build powerful Web applications on the server side. ASP.net offers several advantages beyond the previous Web development model:

• Enhanced performance. ASP.net is the compiled CLR code that runs on the server side, rather than interpreted as an ASP. ASP.net leverages early binding, Just-in-time compilation, local optimization, and caching services to improve performance. All of this, performance is much greater than every line of code you've ever written.

• World class level development tool support. In the visual Studio. NET integrated development Environment (IDE), the ASP.net framework consists of a rich toolbox and designer. WYSIWYG (WYSIWYG) editing, drag-and-drop server controls, and automatic deployment are just a few of the features provided by this powerful tool.

• Strong and resilient. Because ASP.net is based on (CLR), the entire. NET platform is powerful and resilient, and can also be applied to Web application developers. The. NET Framework's class libraries, messaging, and data access solutions can be seamlessly integrated into the Web. ASP.net is also language neutral, so you can choose the language you are most familiar with, or use several languages to work together on an application. Also, the interoperability of the CLR ensures that the existing COM-based development investments remain when you upgrade to Asp.ent.

Simple ASP.net makes it easy to perform common tasks, from simple form submission, client authentication, to deployment and site configuration. For example, ASP.net allows you to create user interfaces that allow you to separate pages from logical code, and to handle events like VB Form execution mode (that is, the page-driven mode becomes the event-driven mode). In addition, the CLR simplifies deployment to manage code services, such as automatic references and garbage collection.

• Easy to manage. ASP.net uses a text-based, layered configuration system that simplifies settings for server-side environments and Web applications. Because the configuration information is saved in plain text format, the new settings do not require support from the local administration tool. This "0 local support" concept is also applied to deploying ASP.net applications. The ASP.net application is deployed to the server, simplifying to replicate the necessary files to the server. There is no need to reboot the server when deploying, or even replacing, the running mutation code.

• Scalability and effective utilization. The asp.net is designed to be scalable to improve performance for clusters and multiprocessor environments. Also, the asp.net runs closely to monitor and manage processes, so that if an error occurs, such as a vulnerability and deadlock, the new process is established at the current location to help your application continue to handle the event request.

• Can be customized and extended. asp.net provides a good extension structure that allows developers to "insert" their code at the appropriate level. In fact, you can either extend or replace any subcomponents of the ASP.net runtime by using your own authored components. It has never been easier to perform custom validation or state services.

Security Built-in Windows validation and individual configurations for each application, you can assume that your application is secure.

The following ASP.net tutorial forces will show you the practice of these concepts

3, Language Support (C # version)

Language support

Microsoft's. NET platform now offers built-in support for three languages: C #, Visual Basic, and Jscript. This textbook practice and example code shows how to use these three languages to build. NET applications. For more syntax information about other languages, refer to the. NET Framework SDK documentation.

The code snippets provided below help you understand the code examples in this textbook and the differences between the three languages.

Variable declaration

The following are the referenced contents:
int x;
String s;
String S1, S2;
Object o;
Object obj = new Object ();
public String name;

Statement

Response.Write ("foo");

Comments

This is a single-line comment

/* This is a multiline comment * *.

accessing indexed properties

The following are the referenced contents:
String s = request.querystring["Name"];
String value = request.cookies["Key"];

Declaring indexed Properties

The following are the referenced contents:
Default Indexed Property
Public String this[string Name] {
get {
Return (String) lookuptable[name];
}
}

Declaring simple properties

The following are the referenced contents:

Public String Name {

get {
...
return ...;
}

set {
. = value;
}

}

Declaring and using enumerations

The following are the referenced contents:

Declare The enumeration
public enum Messagesize {

Small = 0,
Medium = 1,
Large = 2
}

Create a Field or property
Public Messagesize msgsize;

Assign to the property using the enumeration values
Msgsize = Small;

Traverse Collection

The following are the referenced contents:
foreach (String s in coll) {
...
}

Declaration and use methods

The following are the referenced contents:

Declare a void return function
void Voidfunction () {
...
}

Declare a function that returns a value
String stringfunction () {
...
Return (String) Val;
}

Declare a function that takes and returns values
String Parmfunction (String A, string b) {
...
Return (String) (A + B);
}

Use the functions
Voidfunction ();
String S1 = stringfunction ();
String s2 = parmfunction ("Hello", "world!");

customizing properties

The following are the referenced contents:

Stand-alone attribute
[STAThread]

Attribute with parameters
[DllImport ("ADVAPI32.") DLL ")]

Attribute with named parameters
[DllImport ("KERNEL32.") DLL ", CharSet=CharSet.Auto)]

Array

The following are the referenced contents:

String[] A = new string[3];
A[0] = "1";
A[1] = "2";
A[2] = "3";

String[][] A = new string[3][3];
A[0][0] = "1";
A[1][0] = "2";
A[2][0] = "3";

Class

The following are the referenced contents:
String s = "Hello world";
int i = 1;
Double[] A = {3.00, 4.00, 5.00};
If statement
if (request.querystring!= null) {
...
}

Case statement

The following are the referenced contents:

Switch (FirstName) {
Case "John":
...
Break
Case "Paul":
...
Break
Case "Ringo":
...
Break
Default
...
Break
}

For loop
for (int i=0; i<3; i++)
A (i) = "Test";
While loop
int i = 0;
while (i<3) {
Console.WriteLine (i.ToString ());
i + 1;
}

Exception handling

The following are the referenced contents:
try {
Code that throws exceptions
catch (OverflowException e) {
Catch a specific exception
catch (Exception e) {
Catch the generic exceptions
finally {
Execute some cleanup code
}

string concatenation

The following are the referenced contents:

Using Strings
String S1;
String s2 = "Hello";
S2 = "World";
S1 = s2 + "!!!";

Using StringBuilder class for performance
StringBuilder s3 = new StringBuilder ();
S3. Append ("Hello");
S3. Append ("World");
S3. Append ("!!!");

Event Handling delegation

The following are the referenced contents:
void MyButton_Click (Object sender,
EventArgs E) {
...
}

declaring events

The following are the referenced contents:

Create a public event
public event EventHandler MyEvent;

Create a method for firing the event
protected void Onmyevent (EventArgs e) {
MyEvent (this, e);
}

Add or remove event handling to an event

The following are the referenced contents:
Control.change + = new EventHandler (this. Changeeventhandler);
Control.change-= new EventHandler (this. Changeeventhandler);

Structure

The following are the referenced contents:
MyObject obj = (MyObject) session["Some Value"];
Imyobject iobj = obj;

Transformation

The following are the referenced contents:
int i = 3;
String s = i.tostring ();
Double D = double.parse (s);

Class definition with inheritance

The following are the referenced contents:

Using System;

Namespace MySpace {

public class Foo:bar {

int x;

Public Foo () {x = 4;}
public void Add (int x) {this.x = x;}
Override public int Getnum () {return x;}
}

}

Csc/out:librarycs.dll/t:library
Library.cs

Implementing interfaces

The following are the referenced contents:

public class Myclass:ienumerable {
...

IEnumerator Ienumerable.getenumerator () {
...
}
}

class definition with the Main method

The following are the referenced contents:

Using System;

public class Consolecs {

Public Consolecs () {
Console.WriteLine ("Object Created");
}

public static void Main (string[] args) {
Console.WriteLine ("Hello World");
Consolecs CCS = new Consolecs ();
}

}

Csc/out:consolecs.exe/t:exe Console.cs

Standard templates

The following are the referenced contents:

Using System;

public class Module {

public static void Main (string[] args) {
Console.WriteLine ("Hello World");
}

}
Csc/out:consolecs.exe/t:exe Console.cs



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.