asp.net ASP spent two years, three months ago began to transfer to ASP.net, and completed the first Job Employment Center website (HTTP://JOB.N
ju.edu.cn), from one language to another, the process is always difficult, so I want to put me in the process of transformation encountered
Some of
's once very confusing questions have been made into the form of FAQs, hoping to help students who want to transfer to asp.net or
is the revelation, at the same time is also a reason for their own ideas bar ^_^.
PS: I am also a beginner, a lot of understanding is obviously a bit naïve, and did not involve a deeper level, we will do to see
, Look, ^_^
.
1. How to establish asp.net operating environment?
ASP has IIS on it, and ASP.net is simple, as long as you have a. NET Framework on the basis of IIS. That
you want to run ASP.net will be as simple as running ASP, refer to question 2.
Under
is the. NET Framework1.1 download address, just follow the wizard to install the OK!
http://download.microsoft.com/download/7/b/9/7b90644d-1af0-42b9-b76d-a2770319a
568/dotnetfx.exe
2.asp directly in the virtual directory to run on it, that aspx?
the answer is simple: exactly the same:
If you have an example ASPX site, just copy it to a virtual directory you created.
the only thing to be aware of is that if there is a Webconig file, be sure to put it directly under the virtual directory, otherwise there will be error
。 Of course, Microsoft's interpretation of running asp.net may involve a deeper dimension, including private, shared assemblies, permissions
and so on, so he would use the "deployment" of such a large vocabulary, I think for beginners is really a little problem
Masterpiece
and our goal is just to get it to run first:
How does the
3.vs.net build a asp.net application?
I developed using vs.net, so only for this development environment: P. Vs.net the "page" set of ASPX as
is a bit of a beginner's puzzle for the app (I started it this way: P), which makes it easy to think of it with a
SP is almost completely different, but it is not (although the realization of the mind is very different), the individual pages are actually independent of each other
, and ASP, so I would rather call it "Web page." Vs.net to build a asp.net program is actually
is to help you create a virtual directory, and then create a project file (manage multiple ASPX) under this virtual directory. This with D
Reamwaver or FrontPage to establish a site in exactly the same nature, to build such a project just to facilitate the opening of the
the environment to identify which files are included in the current project, the concept of the actual Run-time project does not actually exist.
How is the code in
4.aspx blocked? What is the difference from the ASP?
According to Microsoft's definition, the code in ASPX is to be compiled the first time, which is performed with the program interpretation in ASP
has an essential difference. However, from the results of the operation, these differences can be said to be completely transparent. Understanding the
in ASPX
The key to
code is actually the structure of the code you want to read. The same embedded code as the ASP structure I'm not going to say that.
understand the code behind it is easy to understand.
Do you now feel puzzled at the beginning of an aspx like this? : P
<%@ Page codebehind= "MyDatum.aspx.cs" language= "C #" autoeventwireup= "false" in
herits= "Njujob.mydatum"%>
This is the typical beginning of aspx with vs.net, and I want to look at these properties from a quick start point of view:
@ Page Needless to say, is a sign to describe the page's attribute description
Language: The language used
codebehind: Which file the corresponding code for this page is stored in
Inherits: Which class inherits the page from, in this case the Mydatum class in the Njujob namespace
the latter two attributes are to be understood
code-behind is a unique feature of vs.net (as if not supported by other environments), and it allows programs that correspond to a page to be
logic and presentation logic are separated as two files (this is a distinct difference from the ASP), usually the
structure: sample.aspx The corresponding code file is Sample.aspx.cs (the C # language used), Codebehind will
automatically indicated. Vs.net can compile all code-behind files into a DLL (the so-called assembly) at compile time
, when an ASPX page is processed, the handler can find the inherited class from the inherits, and then locate the
from the DLL
a class and instantiates it to execute the program to get the output of the HTML.
Maybe now everyone has no overall understanding of such an explanation, so please look at the following question:
5. Understand how the code in the asp.net--code file controls the display of the page with an ASP idea?
Consider a simple example, in ASP, if you want to dynamically generate a table inserted into the page, then the practice of
often in the need to insert a part of the program and Response.Write statement to achieve, slightly changed, someone can
can add only one statement at the insertion point <%=strthetalbe%>, and strthetable value may have been
before this
is well calculated, probably through a function, but this calculation is certainly included in this ASP page.
now consider how to implement this process in ASP.net, we first introduce the simplest kind of control, the literal control (
about the control you should have a general idea, is a common program module, such as meaning), the control of the
The
function is to insert a string into a page that has a Text property that you specify as a string
, then this string will be in the corresponding position in the generated HTML file. This should be well understood, with the <%=
in ASP
The function of
strthetalbe%> is almost exactly the same. The literal control is declared in ASPX in the following way:
<asp:literal id= "ltltable" ></asp:Literal>
when you want to use code to control this literal, use the following statement:
ltltable.text= "<TABLE><TR> ...";
This enables the same functionality as the ASP. The code is actually in a hidden file, and there are
in the hidden file class
a declaration to contain such a control, which is usually done automatically by vs.net, namely: You add
to the page
plus a control, vs.net will add the appropriate declaration to your code-behind file. The structural analysis of hidden files can be
to see the next question.
believe that through such an example you should be able to asp.net with the control to achieve the function of text output has a certain understanding, its
more and more complex controls are implemented in exactly the same way, but they provide more functionality for automatic speech, such as a
table controls allow you to directly output a table without having to write HTML code yourself, as to how to accurately control the birth
HTML code will rely on their own experience accumulation and technology upgrade.
6. What is the structure of the hidden code file?
us to actually analyze a file:
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;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
above is the description of which assemblies are referenced, which should be similar to the included files in ASP, and only contain a file to
uses the functions in it, and this side only references an assembly in order to use the controls it provides.
namespace Njujob//description of your assembly namespace (this is not understood for the moment)
{
public class MyDatum:System.Web.UI.Page//This is the ASP.net Page object model (temporarily not
understanding)
~~~~~~~~ This is the inherited property in the ASPX header
{
System.Web.UI.WebControls.Literal ltltable; Declaration of controls on an ASPX page
private void Page_Load (object sender, System.EventArgs e)
{
The program actually starts here and executes the
ltltable.text= "...";
MyFunction ();
}
private void MyFunction ()//You can declare your own function for use on this page
{
}
}
}
This hidden file is compiled into the DLL by vs.net and executed when ASPX is processed.
Well, write these things for the time being, these are the questions that I have just started asp.net to be puzzled, if you happen to
also have the same confusion, then I am happy that I write something can be valuable, if there is any serious error in understanding, but also
please the master not hesitate to enlighten: