?????: asp.NET ???-Behind ???? ????? ???

???? ?????? ???? ??????
???? ID: 303247 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
?? ???? ????? Microsoft .NET ????????? ????? ????????? ???????? ?? ???????? ???? ??::
  • System.Web.UI
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ???? ??? behind ????, ?? asp.NET ??? ???????? ?? ?? ????????? ?????? ?? ?????? ????? ???

???? ???????

ASP.NET ???? ??????? ?? ??? ?? ??????? ?? ?????? ???? ??:
  • ??????-??? ???
  • ??? behind

??? ?? ???-????

??????-??? ??? ?? asp.NET ??? ???????? ??? ???? ????? ??? ?? ???????????? ???? ?? ?????? ??????-??? ??? ????? asp.NET ?????:

Myinlinecode.aspx
<%@ Language=C# %>
<HTML>
   <script runat="server" language="C#">
   void MyButton_OnClick(Object sender, EventArgs e)
   {
      MyLabel.Text = MyTextbox.Text.ToString();
   }
   </script>
   <body>
      <form id="MyForm" runat="server">
         <asp:textbox id="MyTextbox" text="Hello World" runat="server"></asp:textbox>
         <asp:button id="MyButton" text="Echo Input" OnClick="MyButton_OnClick" runat="server"></asp:button>
         <asp:label id="MyLabel" runat="server"></asp:label>
      </form>
   </body>
</HTML>
				

??? Behind

??? behind ?? ??? ???? ????? ??? ????? ?? ?? ???? asp.NET ????? ?? ??? ??? ?? ???????? ???? ??? This allows a clean separation of your HTML from your presentation logic. The following sample illustrates an ASP.NET code-behind page:

MyCodebehind.aspx
<%@ Language="C#" Inherits="MyStuff.MyClass" %>
<HTML>
    <body>
        <form id="MyForm" runat="server">
        <asp:textbox id="MyTextBox" text="Hello World" runat="server"></asp:textbox>
        <asp:button id="MyButton" text="Echo Input" Onclick="MyButton_Click" runat="server"></asp:button>
        <asp:label id="MyLabel" runat="server" />
        </form>
    </body>
</HTML>
				
Mycodebehind.cs
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyStuff
{
    public class MyClass : Page
    {
        protected System.Web.UI.WebControls.Label MyLabel;
        protected System.Web.UI.WebControls.Button MyButton;
        protected System.Web.UI.WebControls.TextBox MyTextBox;

        public void MyButton_Click(Object sender, EventArgs e)
        {
            MyLabel.Text = MyTextBox.Text.ToString();
        }
    }
}
				
In the preceding sample, you can use the following syntax to compile Mycodebehind.cs:
csc.exe /out:mycodebehind.dll /t:library mycodebehind.cs
When you use the following code, the code-behind page inherits from the?????????? The?????class resides in theSystem.Web.UI??? ?????:
public class MyClass : Page
				
Inheriting from the?????class gives the code-behind page access to the ASP.NET intrinsic objects, such as??????, ??????????. In addition, inheriting from the?????class provides a framework for handling events for controls within the ASP.NET page.

??? ????? ????? ??? behind ????? ?? ?????? ???? ?? ???? asp.NET ????? ??? ???????? ??? ??, ?? ?? ???? ??? ?????? ??? behind ???? ??????????? ?? SRC ??? ?? ????? ??:
<%@ Language="C#" Inherits="MyStuff.MyClass" src="MyCodebehind.cs" %>
				
?? ?????? ???, ASP.NET compiles ????? ?? behind-??? ???? ????? ??? ?? ?? compilation ??? ???? ???? ?? ??? behind ????? (?????? ??? ??????????? ???????? ?? ?????? ?? ??? ??) ?????? ???

Visual Studio .NET ??? ??? Behind ??????

?? ?? asp.NET ??? ??????? ????? ?? ??? Microsoft Visual Studio .NET ?? ?????, ??? behind ????? ??????? ???? ???? ???? ???? ???? ?????, Visual Studio .NET ???????? ??? ?? ?? precompilation ???? ?? ??? ?? ?? ???? ?????? ?????? ????? ??? ?? Visual Studio .NET ??? ???? ?? behind-??? ??? ????? ??? ????? ??? ???????Codebehind, ?????? Visual Studio .NET ?? ????? ???? ???

??????

???????? ??????? ?? ??? % 1, ???? ?????? ????? ???? % 2% 2 ???? ?? Microsoft ???????? ??? ?????:
313105BUG: ???? UNC ???? ?? ??? Behind ??????? ?? ????? Src ??????? ???? ?????? ????

???

???? ID: 303247 - ????? ???????: 04 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft ASP.NET 1.1
  • Microsoft ASP.NET 1.0
??????: 
kbinfo kbwebforms kbmt KB303247 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:303247

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

 

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