.NET Framework ??? ?????? ????????????? asp.NET ???? ?? ??? ?????

???? ?????? ???? ??????
???? ID: 976112 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

?????

?? ???? ??? ????? asp.NET ?????? ????????????? ???? ?? ??? ?? ????? ??:
  • <% ... %>
  • <%= ... %>
  • <%@ ... %>
  • <%# ... %>
  • <%$ ... %>
  • <%-- ... %>
  • <%@ ... %>

???? ???????

< %... ??? ??????? %> ?????? ????

???????? ??? ????? classical ASP ?? ??? ???????? ?????? ?? ???????? ???? ?? ??? ????? ???? ???? ??? ????? ??? ??? ???????????? ??? ????????? ?? ????? ???????? ??? ?? ????? ??????? ????? ???? ??? ?????? ?? ??? ?? ???? ????

????????? ???? ?? ????? ?????? ?? asp.NET ????? ????? ?? ?? ???? ??? ?? ?????? ????????? ???? ?? ??? ?? ???????? ??? ????? ??? Microsoft Visual Basic .NET ???:
<%@ Page Language="VB" %>
<html>
<body>
    <form id="form1" runat="server">
    <% For i As Integer = 16 To 24 Step 2%>
    <div style="font-size: <% Response.Write(i)%>">
        Hello World<br />
    </div>
    <% Next%>
    </form>
</body>
</html>
???? ???????? ??? ????? HTML ????? ??? ????? ??????? ??, ??????? ?? ??? ?? ?????? ???? ???? ?? ??? ???????? ?? ??? ???? ???? ???

ASP.NET ??? ????? ??? ???????? ??? ????? ???? ?? ???? ??? ???? ??????? ?? ??? ????? Microsoft ?????? ??????? (MSDN) ??? ???? ?? ????:
HTTP://MSDN.Microsoft.com/en-us/library/ms178135.aspx

< %... %> ????????? ?????????? =

< % %... = > ???????? ??? ??? ?????? ???? Response.Write(?) ??? ?? ?? ???? ?????????? ????????? ?? ??? ??? ?? ??????? ???? ??? ????????, int ?? ?? ?? ?? ???????? ???? ????????? ???? ?? ??? simplest ?? ????? ???

?????? ?? ???, ????? ????? ??? ?? ??????? ??? ????????? ???? ??:
<%@ Page Language="VB" %>
<html>
<body>
    <form id="form1" runat="server">
    <%=DateTime.Now.ToString() %>
    </form>
</body>
</html>
??? ???? ?? ????? ???????? ?? ????????? ??? ????????? ?????????? ?? ????? ???? ?? ???? ???? ?? ???? ??? ?? ???? compiles ??????? ?? ??? ?? ??? ??? ????????? ??????? ?? ????? ?? ???? ?????????? .NET Framework ??????? ???

ASP.NET ?? ??????? ????????? ???? ?? ??? ???? ???? ?? ???? ??? ???? ??????? ?? ??? ????? MSDN ??? ???? ?? ????:
HTTP://MSDN.Microsoft.com/en-us/library/6dwsdcf5.aspx

< % ?? @... %> directive ??????????

Directive ?????????? ?? ???????? ???????? ?? ????? ???? ???? ????? ?????? ?? ?????????? ???????? compilers ?? ?? asp.NET ??? ??????? (.aspx) ?? ??????? ?? ?????????? ???????? (.ascx) ??????? ?? ??? ????????? ?? ????????? ???? ???

ASP.NET ????? ????? ?????? ????? directives:
?? ?????? ?? ??????? ?????? ?????? ?? ??????? ????
@ ?????ASP.NET ????? ?????? ?? ??????? ?????? ????? ??? ???? ??? ?? ?????-??????? ????????? ?? ????????? ???? ??? ?? ???? ??? ???? .aspx ??????? ??? ????? ???? ?? ?????
* ?? directive ??? ???? asp.NET ??? ??????? ??????? ??? ????? ???? ?? ???? ???
@ ????????ASP.NET ????? ?????? ?? ??????? ?????? ????? ??? ???? ??? ?? ????????-??????? ????????? ?? ????????? ???? ??? ?? ???? ??? ???? .ascx ??????? (?????????? ????????) ??? ????? ???? ?? ?????
* ?? directive ??? ???? ?????????? ??? ????? ???? ?? ???? ?????? ????????? ?????
@ ???? ???????? ?????? ??? ?? ???? ???? ??? ????? ??? ??? ????? ?? ??? ?????????? ???????? ??? ???
@ ImplementsDeclaratively ???? ?? ???? ??? ?? ??? ?????????? ???????? ???? ??? ????????? .NET Framework ??????? ????? ???? ???
@ ??????????????? ?? ???? ?? ??? ?? ??? aliases associates ????? ?? ?????????? ???????? ?? ?????????? ?? ?? ?? ??? ???????? ????? ??? ????? ???? ???? ?? ??? ????? ?? ????? ?? ?????????? ???????? ?????
@ ?????????????? ????? ?? ??? compilation ?? ????? ??? ??????? ???? ????? ??? ???? ??? ??????? ?? ???? ?? ??????? ?????? ????? ?? ??? ????? ???
@ ????????? asp.NET ????? ????? ?? ????? ???? ???
@ WebHandler??? asp.NET IHttpHandler ????? ?? ????? ???? ???
@ PreviousPageTypeStrong ????? ?? ????? ????? ?? ?????? ?? ?????? ?? ??? ??? ??????? ???? ?? ??? ??? ????? ?????? ???? ??PreviousPage????
@ MasterType?? ??? ?????? ?? ??? ????? ???? ??????????? asp.NET ????? ?? ???? ASP.NET ????? ????? ?? ?????? ????? ?? ?????? ????? ?? ?? ????? ?????? ???? ???
@ OutputCache???? ????? ?? ?? ???? ?????????? ???????? ?? ???? ??? ?????? declaratively ????????? ?????
@ ????????????? ????? ?? ?????????? ???????? ???? ?? ??? ????? ?? ?????????? ???????? declaratively ?????
Directive ???????? ?? ???? ??? ???? ??????? ?? ??? ????? MSDN ??? ???? ?? ????:
HTTP://MSDN.Microsoft.com/en-us/library/xz702w3e.aspx

< % #... %> ????-???????? ??????????

???? ???????? ?????????? ?? ??? ????? ???????? ?? ??? ?? ?? ???? ?? ??? ???????? ????? ?? ?? ????? ????????DataBind????? ?? ?? ????? ???????? ?? ?????? ?? ??? ???? ???? ???

????? ?????? ?? ??? ??? ?????? ?? ???????? ?? ????? ???? ?? ??? ????-???????? ?????????? ?? ????? ???? ???? ?? ?????? ???????? ???? ???:
<%@ Page Language="VB" %>
<script runat="server">
    Protected Function SayHello() As String
        Return "Hello World"
    End Function

    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
        lblHello.DataBind()
    End Sub
</script>
<html>
<body>
    <form id="form1" runat="server">
    <asp:Label ID="lblHello" runat="server" Text="<%# SayHello%>"></asp:Label>
    </form>
</body>
</html>
???? ???????? ?????????? ???????? ?? ???? ??? ???? ??????? ?? ??? ????? MSDN ??? ???? ?? ????:
HTTP://MSDN.Microsoft.com/en-us/library/bda9bbfx.aspx

< % $... %> ?????????? ??????

?????????? ?????? ???????? ?? ??? ???? ????????? ?? ??????????? ?? ?????? ??????? ??? ????? ??????? ?? ?????? ?? ??? ?? ??? ???? ?? ??? ????? ???? ???? ??? ?????????? ?????? ?? ??? ???????? ????? ??:
<%$ Expression Prefix: Expression Value %>
????? ???? ???? ????? ($) ?? asp.NET ???? ?? ??? ?? ????? ?????????? ??? ?????????? ?????? ??? ?????????? ?????? ????????? ?????? ?? ?????????? ??, ????AppSettings,ConnectionStrings??,??????. ??? ??, ?? ?? ???? ??? ????? ?? ???? ?????????? ?????? ????????? ????? ?? ?????? ???????? ?????????? ??? (:) ?? ???? asp.NET ?????? ??? ????? ?? ???? ????? ??? ?? ??? ?? ??? ????

The following demo shows how to use the expression builder to obtain the copyright of a Web site from theAppSettingsnode in the Web.config file and how to then set the copyright information as the value of the Literal?s???????

TheAppSettingsnode in Web.config file:
<appSettings>
    <add key="copyright" value="(c) Copyright 2009 WebSiteName.com"/>
</appSettings>
The expression builder in the ASP.NET Web Form page:
<div id="footer">
    <asp:Literal ID="Literal1" runat="server" Text="<%$ AppSettings: copyright %>"></asp:Literal>
</div>
For more information about ASP.NET expressions, visit the following MSDN Web site:
http://msdn.microsoft.com/en-us/library/d5bd1tad.aspx

<%-- ... -- %> server-side comments block

The server-side comments block lets developers embed code comments in any location of the HTML source of ASP.NET Web Form pages (except for within<script></script>

????? ??? ?????? ?? ?? asp.NET ??? ??? ?????-???? ?????????? ??? ?? ????? ???? ?????? ??:
<%@ Page Language="VB" %>
<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim strName As String
        strName = Session("userName")
        lblUserName.Text = strName
    End Sub
</script>
<html>
<body>
    <form id="form1" runat="server">
    <%-- Label for UserName --%>
    <asp:Label ID="lblUserName" runat="server" Text=""></asp:Label>
    </form>
</body>
</html>
?????-???? ?????????? ?? ???? ??? ???? ??????? ?? ??? ????? MSDN ??? ???? ?? ????:
HTTP://MSDN.Microsoft.com/en-us/library/4acf8afk.aspx

???

???? ID: 976112 - ????? ???????: 06 ?????? 2010 - ??????: 3.0
???? ???? ???? ??:
  • Microsoft .NET Framework 2.0
  • Microsoft .NET Framework 3.0
  • Microsoft .NET Framework 3.5
??????: 
kbsurveynew kbinfo kbhowto kbexpertiseadvanced kbmt KB976112 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:976112

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com