惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 聂微东
月光博客
月光博客
博客园 - 司徒正美
爱范儿
爱范儿
aimingoo的专栏
aimingoo的专栏
量子位
Recent Announcements
Recent Announcements
V
V2EX
P
Proofpoint News Feed
小众软件
小众软件
云风的 BLOG
云风的 BLOG
腾讯CDC
宝玉的分享
宝玉的分享
Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
B
Blog
博客园_首页
GbyAI
GbyAI
博客园 - Franky

博客园 - 眼里进了砂

Unity Application Block 1.2 学习笔记 [转] Unity Application Block 與 ASP.NET MVC 學習資源整理 [转] 线程之间的通讯---SynchronizationContext [转] .NET2.0中WinForm自定义的程序配置[转] 使用BackgroundWorker组件进行异步操作编程[转] .NET页面事件执行顺序[转] 不用设置iis .net 实现urlrewrite[转] 利用XPath读取Xml文件 javascript中replace与正则表达式 c# BackgroundWorker组件介绍(属性、方法、事件) .net 2.0 BackgroundWorker类详细用法 .Net的线程同步方法一:ManualResetEvent .NET应用程序中异步调用Web Service的几种方法 come from: veryhappy(wx.net) [转][javascript] Google谷歌首页点点效果 AJAX 中Sys.WebForms.PageRequestManager的事件激发顺序 AJAX 中Sys.Net.WebRequestManager的事件激发顺序 Summary review about Problem.Design.Solution 2 [转发]深入理解 __doPostBack CSS Tips
Summary review about Problem.Design.Solution
眼里进了砂 · 2007-05-30 · via 博客园 - 眼里进了砂

<!-- add on 07/05/30 -->


1.  Avoid using HTML Tables to control layout
     It is highly recommended for developers to use DIVs and separate stylesheet file to define appearance and position instead of using the traditional HTML Table. CSS styles and DIVs provide greater flexibility than tables.
   


2.  Only set the MasterPageFile property in the Page_PreInit event handler to change the MasterPage dynamically
     You can only set the MasterPageFile property in this event handler because the merging of the two pages must happen very early in the page's life cycle, the Load or Init event would be too late.


 

3.  @MasterType directive and the appropriate solution for providing different layouts
     We can use this.Master as a reference to its master page after adding the @MasterType directive
<%@ MasterType VirtualPath="~/MasterPage.master" %> .
     Because we can't dynamically change the master page's type at runtime. For this reason we will not use different master pages to provide different layouts to the user. We can completely change the appearence of the page by applying different styles to it.


 

4.  Specify the Theme and MasterPage
   
To apply a theme to a single page, you use the Theme attribute in the @Page directive:
     <%@ Page Language="C#" Theme="NiceTheme" MasterPageFile="~/MasterPage.master" ... %>     To apply it to all pages, you can set the theme attribute of the <pages> element in web.config, as follows:
     <pages theme="NiceTheme" masterPageFile="~/MasterPage.master" />


 

5.  DIVs properties in CSS Style
     If you don't specify an explicit width and don't use absolute positioning, a DIV will always have an implicit width of 100%.

     #loginbox
   {
      position: absolute;
      top: 16px;
      right: 10px;
      width: 180px;
      height: 80px;

      padding: 2px 2px 2px 2px;
      font-size: 9px;

   }
    
    It uses absolute positioning, its position relys on the top and right property that you specified. 


 

6.  NameSpace, Cache and Server methods in Class files
     You can add a NameSpace into a class files, then in another aspx.cs file, just simply import the namespace and directly use its methods.
     We can use such as Cache.add and Server.MapPath in an ordinary aspx.cs page. However, we have to use the HttpContext.Current.Cache and HttpContext.Current.Server.MapPath methods in a seperate cs class.
     CacheDependency can be used to cache some information until the dependent item changes.

     CacheDependency dep = new CacheDependency(themesDirPath);
     HttpContext.Current.Cache.Insert("SiteThemes", themes, dep);
     In this case, the cache 'SiteThemes' will be kept until the dependency themesDirPath changes.
 

7.  File Operation
     To operate the folders, use the Directory.GetDirectories(themeDirPath) and Path.GetFileName(xxx[i]) to retrive the folders entire physical path or the folder name.

     To manipulate the files, use the Directory.GetFile(themeDirPath) and FileInfo class to retrieve the file information such as file name, update time and so on. 


 

8.  Control.UniqueID
     We can use the Control.UniqueID to retrive the rendered control's ID even though this control is embeded in a Component such as User Control. i.e, ctl00_LoginView1_Login_UserName.


 

9.  Customize BasePage class and __EVENTTARGET
     To implement some special events in particular page, we need to customize a BasePage class, inheriting from the System.Web.UI.Page and overriding some base's events such as OnPreInit and


OnLoad events. After that, inherit this customized BasePage class in every aspx.cs page to inplement the events you specified in the BasePage class.
     We can use this.Request.Form["__EVENTTARGET"] to retrieve the ID of Control that triggerd the postback event except the Button Control and ImageButton Control (We can use another approach to check this two kinds of Controls, refer to an article posted previously)