Hjr-asp.net: Create a asp.net page __.net

Source: Internet
Author: User

asp.net schema Web Forms html+ajax+ashx MVC

asp.net

Asp. NET and JSP, PHP is the obvious difference is asp.net with a. NET Framework this makes asp.net become very convenient, after learning asp.net not to learn the ASP, did not learn the direct learning asp.net on the line. In fact, if you learn asp.net after learning PHP, JSP frame will have a sense of epiphany. Architecture Web Forms

This is the simplest architecture, consisting of two parts. aspx files and. cs files. aspx files are the equivalent of HTML files that can be inserted into C # code, and CS files are written in the C # language background.

Web forms Convenient place is, the control adds a property runat= server, can in the background directly with the control ID directly manipulate the control, such as directly write TextBox1.Text = "Hellow,world"; You can set the ID to the TextBox1 control value directly to display as Hello,world. And because ASP.net is developed using Visual Studio, you can simply click on the design, drag the control can be dragged out of the interface.

So asp.net web site process is the new-> website->asp. NET empty Web site right-click Solution-> Add New Item->web form is determined, two files appear. aspx and. cs in the. aspx file-> Click the lower left corner of the design drag control or left corner source programming HTML code to write both C # background logic and database, and so on-> Then right-click the file to view it in the browser.

Next. cs file

public partial class ClassName:System.Web.UI.Page
{
    protected void Page_Load (object sender, EventArgs e)
    {
        if (! IsPostBack) {}//is only performed on the first time the page is opened}
}

The following Page_Load are the methods that are executed after the page is opened, in which you can invoke other methods.

Web forms is an event-driven,. aspx file drag button and then double-click, then. cs file Write-processing code implements the buttons event

So two files make up an interface, and many interfaces make up a Web site.

If you want to put the duplicate code together, you can build a Web project while building a DLL class library project, they put in the same solution, so that after editing the DLL
You can simply reference and test the html+ajax+ashx with a Web project

If your HTML page is a ready-made template and you don't want to make too many changes to the file, you can use this architecture, just write the Ajax code to the ashx file on each HTML page that needs to interact. ASHX files can be multiple or a file can handle requests for different HTML pages through a switch. Online download site templates, the entire copy to the project in any HTML file written by the button triggered by the Ajax code, URL fill ashx file path in the ashx file write operations database return data processing MVC

This option adds the project->asp.net the Web application and then selects MVC, and the MVC introduction can find the data on its own. As for the cshtml file introduction is similar to the ASP page html+c# code Dynamic View file, relatively new and simpler.

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.