| Yousoft.hi.com.cn by Xu Changyou Generally, developers are required to design background programs for website construction. There are professional artists in front to design the interface. Although developers sometimes do some interface design, they usually cannot meet professional requirements. In the past ASP, due to the mixing of code and HTML page language, website construction became quite difficult. But in ASP. NET, this situation has completely changed. The following describes how to use C # Builder to create a simple ASP. NET application. Open C # Builder and choose File> New> other... Menu items, you will see the following window: Select C # ASP Projects and you will see three options on the right. Select ASP. NET Web Application to create the first ASP. NET Application. C # Builder will automatically create a virtual directory under the wwwroot directory where the Web program is located, which is called WebApplication1. You can get another name based on the program function. When you open IIS, you will find that a virtual directory named WebApplication1 is generated. If it is not automatically created, you can use IIS to create a virtual directory. You will see that C # Builder automatically creates a Web page named WebForm1. Put a label and a button here. (Note: HTML Label and HTML Button ), Run the program by pressing F9 and you will see a simple ASP. NET Web page. Is it easy?
Below is the HTML page we created <% @ Page language = "c #" Debug = "true" Codebehind = "WebForm1.aspx. cs" AutoEventWireup = "false" Inherits = "myaspx. WebForm1" %> <! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<Html> <Head> <Title> </title> <Meta name = "GENERATOR" content = "Borland ASP. NET Designer for c # Package Library 7.1"> </Head> <Body ms_positioning = "GridLayout"> <Form runat = "server"> <Input style = "Z-INDEX: 2; LEFT: 246px; WIDTH: 75px; POSITION: absolute; TOP: 150px; HEIGHT: 24px" Type = button size = 25 value = OK> <span title Style = "Z-INDEX: 1; LEFT: 86px; WIDTH: 187px; POSITION: absolute; TOP: 86px; HEIGHT: 27px"> my ASP. NET program! </Span> <font color = # ccffcc> </font> </Form> </Body> </Html> From the first line, we can see that the background code of this page is all in the WebForm1.aspx. cs file. You can write a program in this file. The generated code is as follows: Using System; Using System. Collections; Using System. ComponentModel; Using System. Data; Using System. Drawing; Using System. Web; Using System. Web. SessionState; Using System. Web. UI; Using system. Web. UI. webcontrols; Using system. Web. UI. htmlcontrols; Namespace myaspx { /// <Summary> /// Summary description for webform1. /// </Summary> Public class webform1: system. Web. UI. Page { Private void page_load (Object sender, system. eventargs E) { } # Region web form designer generated code Override protected void oninit (eventargs E) { // // CODEGEN: This call is required by the ASP. NET Web Form Designer. // InitializeComponent (); Base. OnInit (e ); }
/// <Summary> /// Required method for Designer support-do not modify /// The contents of this method with the code editor. /// </Summary> Private void InitializeComponent () { This. Load + = new System. EventHandler (this. Page_Load ); } } } After code execution, developers can directly modify the. cs file. Page designers can modify HTML pages, which greatly simplifies the website construction process. |