Create the first ASP.net application (section 1th) _ Practical Tips

Source: Internet
Author: User

In this section, we learn to create a page that displays the appropriate welcome information based on user input, and I hope my friends can work with me.
Learning content:
First step, create asp.net program
1, run Visual Studio 2008. In the menu bar, select "File" → "new" → "project" command, in the New Project dialog box that pops up, select the Visual Studio Solution option in the other project type tree directory on the left, and select in the Visual Studio installed Templates option area on the right The Blank Solution option, which is named "0931" for the solution, and then click OK.
2, in the Solution Explorer window, right-click Solution 0931, select the Add → new Web site command from the pop-up shortcut menu, and then in the Add New Web Site dialog box, select ASP. NET Web site option; In the options area below the dialog box, select the file system option in the Location Drop-down list, select the Visual C # option in the Language Drop-down list: Click the browse button to select a site path: e\0931\chap1, click OK.
3, you can see what visual Studio automatically generates by using the Solution Explorer panel on the right side of the Web Forms page. Where App-data is the data folder for the application, Default.aspx is a blank Web Forms page, is the default homepage of the Web site, Default.aspx.cs the back file for its code. Move the mouse pointer over the Toolbox tab on the left side of the Web Forms page to see the various types of ASP.net controls in the expand Toolbox, just double-click the control when you add the control, or drag space directly onto the Web Forms page.

The second step, the control design of Web Forms page
1. In Visual Studio 2008, in the Solution Explorer panel, right-click the site name Chap1, select Add New Item from the pop-up shortcut menu, and select the Web Forms option in the Add New Item dialog box that pops up. The name is chap1-1.aspx, and the "put code in a separate file" option is selected by default, and click the Add button.
2, switch to Design view, add controls for the Chap1-1.aspx page, drag 1 image controls from the left Toolbox Standard Group, 3 lable controls, 1 TextBox controls, 1 button controls, and a LinkButton control. The first method enables you to right-click the control in Design view, select Properties on the pop-up shortcut menu, open the Properties window, and set properties for the control such as:

The second method can also add control properties and property values in source code view.
step three, event handling and code behind , double-click the Button1 control in the Design view of the Chap1-1.aspx page to automatically add a property and property value for the Button1 control:

Onclick=button1_click. Write the following code in the Button1_Click event of the Chap1-1.aspx.cs code file: Public partial class Chap1_1:system.web.UI.page
 {
 protected void Page_Load (Object Sender,eventargs e)
 {
 }
 protected void Button1_Click (Object Sender,eventargs e)
{
 string Hello=textbox1.text.trim () + "classmate, welcome you!" ";
 Lable3.text=hello
 }
}

Step Fourth, WEB. Config configuration file
Finally, click the "Start Debugging" button in the Standard toolbar to run chap1-1.aspx. Note In the pop-up dialog box, select "Run Without Debugging" and click OK.

Run Effect chart

Summarize
Today, the small series created the first ASP.net application, although there are many imperfect places, the layout is not fine, beautiful; In the course of the operation also occurred errors, repeat operation, open the page when the picture can not open, found that the reason is not the correct path of the specified picture, But through this lesson, learned a lot of skills, opened the asp.net wonderful journey.

I hope you can and small weave together to explore and learn together.

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.