ASP.NET 2.0 new features

asp.net

 
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" 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);
    }

}

时间: 2024-08-07 15:03:29

ASP.NET 2.0 new features的相关文章

扩展ASP.NET 2.0资源提供程序模型(1)

摘要: Microsoft ASP.NET 2.0 在本地化 Web 应用程序方面进行了许多奇妙的改进.即使有了所有这些奇妙的优点,但在本地化站点后不久,您可能还会开始考虑扩展性.本文将帮助您应用 ASP.NET 的扩展功能处理企业本地化方案并改进本地化开发过程. 简介 ASP.NET 2.0 在本地化 Web 应用程序方面进行了许多奇妙的改进.我曾在 MSDN 文章"ASP.NET 2.0 Localization Features: A Fresh Approach to Localizin

ASP.NET 2.0 Treeview Checkboxes - Check All - Javascript

asp.net|javascript|treeview ASP.NET 2.0 TreeView has many built-in features such as showing a checkbox for all the Tree Nodes. Node level formating, style, etc., Enabling the ShowCheckBoxes="All" property sets it to show a checkbox for all the n

在asp.net 2.0中结合母板页使用meta标签(扩展@Page指令)

asp.net 介绍母板页是asp.net 2.0中的一个非常强大的特性,但是它却不能提供一个实现最基础的针对搜索引擎优化的方法.如果你想你的web页被搜索引擎收录并提高排名,那么你就需要在每一个页都指定一个title和meta标记.本文将说明如何扩展你的asp.net页,以使得在使用母板页的时候你可以直接在你内容页的@Page指令中指定你的meta标签的描述和meta标签的关键字 背景当你要针对搜索引擎优化你的web页的时候,设置页的title标签和页的meta描述是其中最重要的因素之一.<t

解读ASP.NET 2.0 Internals

asp.net IntroductionNew features are fun and interesting to learn about, but changes to the core structure of ASP.NET speak louder to developers who really want to master the technology. In this white paper, we will cover how the internal structure o

ASP.NET 2.0数据教程之七十四:调试存储过程

返回"ASP.NET 2.0数据教程目录" 导言: Visual Studio有很多的调试功能.我们只需要稍稍点点鼠标, 敲敲键盘就可以使用断点(breakpoints)来打断某个程序的执行,并查看其状态. 除了调试代码以外,Visual Studio也支持对SQL Server里面的存储过程进行调试 .就像可以在ASP.NET页面的后台代码类或Business Logic Layer class类里设置 断点一样,我们也可以在存储过程里设置断点. 本文我们将考察如何在 Visual

在ASP.NET 2.0中操作数据之二十五:大数据量时提高分页的效率_自学过程

导言 如我们在之前的教程里讨论的那样,分页可以通过两种方法来实现: 1.默认分页– 你仅仅只用选中data Web control的 智能标签的Enable Paging ; 然而,当你浏览页面的时候,虽然你看到的只是一小部分数据,ObjectDataSource 还是会每次都读取所有数据 2.自定义分页– 通过只从数据库读取用户需要浏览的那部分数据,提高了性能. 显然这种方法需要你做更多的工作. 默认的分页功能非常吸引人,因为你只需要选中一个checkbox就可以完成了.但是它每次都读取所有的

在ASP.NET 2.0中操作数据之七十二:调试存储过程_自学过程

导言: Visual Studio有很多的调试功能.我们只需要稍稍点点鼠标,敲敲键盘就可以使用断点(breakpoints)来打断某个程序的执行,并查看其状态.除了调试代码以外,Visual Studio也支持对SQL Server里面的存储过程进行调试.就像可以在ASP.NET页面的后台代码类或Business Logic Layer class类里设置断点一样,我们也可以在存储过程里设置断点. 本文我们将考察如何在Visual Studio的Server Explorer里进入存储过程并设置

在ASP.NET 2.0中操作数据之三:创建母版页和站点导航_自学过程

导言 通常,用户友好的个性化站点都有着一致的,站点统一的页面布局和导航体系.Asp.net 2.0引入的两个新特性给我们在统一站点的页面布局和站点导航上提供了简单而有效的工具,它们是母板页和站点导航.母板页允许开发者创建统一的站点模板和指定的可编辑区域.这样,aspx页面只需要给模板页中指定的可编辑区域提供填充内容就可以了,所有在母板页中定义的其他标记将出现在所有使用了该母板页的aspx页面中.这种模式允许开发者可以统一的管理和定义站点的页面布局,因此可以容易的得到拥有统一的视觉和感觉的页面并且

在ASP.NET 2.0中操作数据之六十:创建一个自定义的Database-Driven Site Map Provider_自学过程

导言: ASP.NET 2.0的网站地图(site map)功能允许页面开发者在一些持久介质(persistent medium),比如一个XML文件里,自己定义一个web程序的site map.一旦定义了之后,我们可以通过System.Web命名空间的SiteMap class类或某个Web导航控件,比如SiteMapPath, Menu, 或TreeView来对其进行访问.site map系统使用的是provider model模式,所以可以创建不同的site map,并将其应用到一个web