我的KM

收藏信息:互联网、博客、科技、娱乐、健康、摄影、软件开发、Web设计、DotNet、ASP.NET2.0

  DonewsBlog  |  Donews首页  |  Donews社区  |  Donews邮箱  |  我的首页  |  联系作者  |  聚合   |  登录
  50篇文章 :: 0篇收藏:: 11篇评论:: 8个Trackbacks

公告

[收藏]365Key|和讯网摘|博采|VIVI|狐摘

Bloglines订阅 Newsgator订阅 My Msn订阅 My Yahoo订阅 Rojo订阅 gougou订阅 周博通订阅 博阅订阅 Rsshow订阅 Google Reader

文章

收藏

相册

A 友情链接

B 在线工具

C 技术站点

D MyFavorites

E 故地重游

存档


正在读取评论……


B1 ASP.NET 2.0

http://ryanfarley.com/blog/archive/2004/06/16/788.aspx

One of the cool new things introduced in ASP.NET 2.0 is Master Pages. Master Pages give you the ability to define a master page layout and look that is used throughout a site to give a consistent look & feel to all pages. Any updates or changes to the look & feel of the site is done in only one place - the Master Page. Something that might be useful is the ability to dynamically load a master page at runtime, for example based on user preferences or to implement a simple skinning ability for a site framework that might host multiple different sites (something like .Text). It is not a difficult task and can be done very generically to make for easy reuse.

The master page can be selected for a page easily at design-time, I won't focus on that here. But assigning a master page at run-time can only be done in the OnPreInit event since the rendering of the page with the master page occurs prior to the Init event. However, in the case where you want to load the master page dynamically, for example from a database entry based on a user's preference or something, you don't want to add code to the OnPreInit event on every page in the site. It is easy enough to add that code to a base page class that you can inherit from for you pages in the site.

public class DynamicPage : System.Web.UI.Page
{
    protected override void OnPreInit(EventArgs e)
    {
        string masterfile = getMasterPageFromDatabase();
        if (!masterfile.Equals(string.Empty))
        {
            base.MasterPageFile = masterfile;
        }
        base.OnPreInit(e);
    }
}

Now, all you have to do is inherit from that class for all the pages in the site. But this is where it gets even cooler. I posted before about some cool changes for the web.config file in ASP.NET 2.0. So now, you don't even have to change each page class in your web application to inherit from our new DynamicPage class. You can just add it into the web.config and all pages will automatically inherit from it. Doesn't matter if it is a page in the project that you have already, or a new page you add later, it will know to inherit from the DynamicPage class. You add the following to the web.config:

<system.web>
    <pages pageBaseType="DynamicPage" />
    <!-- ...rest of system.web items... -->
</system.web>

Make sure to include the fully-qualified name, including namespace(s) if appropriate, but that is it. I did a quick test and threw a couple of master pages together to test it out. I also added a property to my DynamicPage class to allow for setting the master page file at runtime from a page that inherits from the class and I added a dropdown to allow the master page to be selected by the user. The property I added just stores the master page file name and reloads the current page so the PreInit would fire again, nothing too fancy. Here's some quick images of the pages with the different master pages applied to it (as selected by the user at run-time)

       

Gives a quasi-skinning feel to the site, none of the content pages need to change - and took me all of about 5 minutes to do. All you need to do is implement separate master pages for each look - which is brain-dead easy. I didn't make my master pages anything fancy at all, but changed enough to demonstrate a different look and layout for each master. Don't forget that this does not replace other good design habits, you can still implement the parts that make up the master page as user controls so you're not building things more than once. You can use this same idea with ASP.NET 2.0 themes to load themes for controls at run-time also.


原文:http://www.microsoft.com/china/msdn/Library/WhitePaperSolution/WPBCSiFSfinal.mspx


图 1:Microsoft 企业应用程序开发平台核心层


图 2:Microsoft 企业应用程序开发平台核心技术和产品

Allstate 使用 Web 服务快速创建保单管理解决方案
利用 Microsoft Visual Studio .NET 和 .NET Framework,Allstate 在 7 个月内即完成 Countrywide Producer Network 联网
美洲银行某部门自动生成预测,将创建报表的时间缩短了 98%http://www.Microsoft.com/resources/casestudies/CaseStudy.asp?CaseStudyID=16280
Bank of Montreal将员工工作效率提高了 23%
Bank of Montreal选择 Microsoft .NET 和智能客户端体系结构构建任务关键的客户服务应用程序
由于采用标准化的 Microsoft 技术和协作软件,Barclays 预测将获得丰厚回报
Bear Stearns 将库存定单功能扩展到其开发人员以及其他人员
Broadspire -从大型机迁移出来降低了 98% 的运营成本,并在 2 个月后产生投资回报
Citigroup CitiVision 集成了 270 个不同的信息源,供投资银行业中 12,000 个全球用户使用
Corillian 公司帮助银行解决方案提供商超越关键基准结果
全美金融机构 Balboa 保险集团选择 BizTalk Server 2004 来管理每天多达 100,000 份的票据以跟踪有关 1400 万宗贷款的信息。
Dell 销售工具可以减少 Dell 10%(或更多)的销售通话时间并大幅度提高收益率
通过将超级计算机部署到 Windows(而非 Linux),Equifax 将总拥有成本降低了 14%
Farmers Insurance 保险公司通过基于 Web 服务的解决方案简化索赔处理
构建基于 FIX.NET 的自动交易系统助推 JPMorgan Chase 提高开发效率
伦敦股票交易所利用 Windows Server 2003 和 Visual Studio .NET 2003 实现瞬间股市信息传送
Merrill Lynch & Co.高性能数据库帮助证券经纪公司为将来的发展做好准备
NASDAQ 主要证券市场站点提高了可靠性、安全性和性能,同时降低了运营成本
塞尔维亚国家储蓄银行 (NSBS) 从规划到开始运营仅用了 3 个星期
Reuters 全球信息提供商使用 Web 服务降低服务成本
SunGard 使用 Microsoft .NET 提高开发人员工作效率并改进客户解决方案
TSYS 信用卡处理机构使用报表解决方案提高灵活性并缩短开发时间
UnumProvident 通过基于 Web 的数据系统提高工作效率
Wells Fargo身份管理解决方案节省了 350,000 美元,开发速度加快了 25%新程序在线使用,该解决方案提高了敏捷性。
XRT 利用 .NET Framework 和 Web 服务实现现金和财务管理套件

MSDN 最新技术文章Microsoft 企业开发策略汇编 “Microsoft 的企业开发策略汇编”简介白皮书旨在为开发人员、架构师及 IT 管理人员提供 Microsoft 应用程序开发技术的概况和技术信息。

MSDN 最新技术文章

Visual Studio Tools for Office Version 2005 中的服务器功能概述
学习使用 Microsoft Visual Studio Tools for the Microsoft Office System Version 2005 Beta 1(使用 Microsoft Office Word 2003 和 Microsoft Office Excel 2003)在服务器上创建服务器解决方案。

T-SQL 编码标准 这个很好,英文版的SQL语法的编码规范。包括如何定义表、存储过程等。

透明原则(软件业务) 讲你出产的软件产品应该具有哪些希望大家都明了的方面。

通过代码演示 Avalon 与 Windows 窗体的互操作性

XML 专栏:C-Omega 概述

创建动态数据输入用户界面  


第1页,共1页