在asp.net 2.0中,只需要在web.config里定义你要用的那些namespace,则在aspx页面中就不需要再象1.1那样,用
<%@ import namespace="system.text" %>来引用了。比如,只需要在web.config中,以这样的方式就可以了:
 <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web>
  <system.web> <pages>
    <pages> <namespaces>
      <namespaces> <add namespace ="System.IO" />
        <add namespace ="System.IO" /> <add namespace="System.Text"/>
        <add namespace="System.Text"/> </namespaces>
      </namespaces> </pages>
    </pages> </configuration>
  </configuration> </system.web>
</system.web>  这样一来,在所有的aspx页面中(注意不是codebehind页面),则不需要再用import的方法引入了。
  同样道理,在asp.net 1.1中,自定义控件的引用,在aspx页面中也是很麻烦的,在asp.net 2.0中,可以在web.config中这样定义:
 <%@Register TagPrefix="uc" Namespace="xxxxxx" Assembly="xx" %>
<%@Register TagPrefix="uc" Namespace="xxxxxx" Assembly="xx" %> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web>
  <system.web> <pages>
    <pages> <namespaces>
      <namespaces> <add namespace ="System.IO" />
        <add namespace ="System.IO" /> <add namespace="System.Text"/>
        <add namespace="System.Text"/> </namespaces>
      </namespaces> <controls>
      <controls> <add tagPrefix="uc" namespace="xx" assembly="xxxx" />
        <add tagPrefix="uc" namespace="xx" assembly="xxxx" />  </controls>
      </controls> </pages>
    </pages> </configuration>
  </configuration> </system.web>
</system.web>
这样,在aspx页面中,只需要用uc来引用就可以了,十分方便。
 
                    
                     
                    
                 
                    
                 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号