国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET 2.0 new features

2024-07-10 12:55:27
字體:
來源:轉載
供稿:網友
 

from quickstart:

simplified code behind model new in 2.0

asp.net 2.0 introduces an improved runtime for code-behind pages that simplifies the connections between the page and code. in this new code-behind model, the page is declared as a partial class, which enables both the page and code files to be compiled into a single class at runtime. the page code refers to the code-behind file in the codefile attribute of the <%@ page %> directive, specifying the class name in the inherits attribute. note that members of the code behind class must be either public or protected (they cannot be private).

c# codebehind code separation
 
the advantage of the simplified code-behind model over previous versions is that you do not need to maintain separate declarations of server control variables in the code-behind class. using partial classes (new in 2.0) allows the server control ids of the aspx page to be accessed directly in the code-behind file. this greatly simplifies the maintenance of code-behind pages.



這對開發來說確實是一個改進,codebehind中去掉server control的聲明會使代碼"清爽"很多,看起來舒服多了。請看示例:

這對開發來說確實是一個改進,codebehind中去掉server control的聲明會使代碼"清爽"很多,看起來舒服多了。請看示例: 頁面中我們放置一個textbox:test.aspx
<%@ page language="c#" codefile="test.aspx.cs" inherits="test_aspx" %>

<html>
<head>
    <title>test asp.net 2.0</title>
</head>
<body>
    <form runat="server">
      <asp:textbox id="textbox1" runat="server"/>
      <asp:button id="button1" text="click me" onclick="button1_click" runat="server"/>
      <br />
      <br />
    </form>
</body>
</html>test.aspx.csusing system;

public partial class test_aspx: system.web.ui.page
{
    protected void button1_click(object sender, eventargs e)
    {
        response.write ( "hi,you have entered the word: " + textbox1.text);
    }

}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 池州市| 新宁县| 永康市| 科技| 大渡口区| 曲水县| 偃师市| 商丘市| 图木舒克市| 株洲市| 岳西县| 塔河县| 泰顺县| 都江堰市| 微博| 长宁县| 齐河县| 凉山| 松桃| 余干县| 察哈| 南安市| 蓬安县| 巴马| 定西市| 抚顺市| 海宁市| 阜康市| 平罗县| 牟定县| 荔浦县| 清丰县| 启东市| 靖州| 东平县| 开阳县| 巴中市| 马龙县| 香格里拉县| 崇明县| 芜湖县|