ASP.NET中aspx页面


  本文标签:aspx页面 ASP.NET

  看上去这个题目比较长,但实际上,我在看资料时发现,这就是说,在ASP.NET 2.0中,只需要在web.config里定义你要用的那些namespace,则在aspx页面中就不需要再象1.1那样,用< %@ import namespace="system.text" %>来引用了  。

  比如,只需要在web.config中,以这样的方式就可以了

  1. <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> 
  2. <system.web> 
  3. <pages> 
  4. <namespaces> 
  5. <add namespace ="System.IO" /> 
  6. <add namespace="System.Text"/> 
  7. namespaces> 
  8. pages> 
  9. configuration> 
  10. system.web> 

  这样一来,在所有的aspx页面中(注意不是codebehind页面),则不需要再用import的方法引入了.

  同样道理,在ASP.NET 1.1中,自定义控件的引用,在aspx页面中也是很麻烦的,在ASP.NET 2.0中,可以在web.config中这样定义

  1. <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> 
  2. <system.web> 
  3. <pages> 
  4. <namespaces> 
  5. <add namespace ="System.IO" /> 
  6. <add namespace="System.Text"/> 
  7. namespaces> 
  8. <controls> 
  9. <add tagPrefix="uc" namespace="xx" 
  10. assembly="xxxx" /> 
  11. controls> 
  12. pages> 
  13. configuration> 
  14. system.web>