看上去這個題目比較長,但實際上,我在看資料時發現,這就是說,在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">
<system.web>
<pages>
<namespaces>
<add namespace ="System.IO" />
<add namespace="System.Text"/>
</namespaces>
</pages>
</configuration>
</system.web>
這樣一來,在所有的aspx頁面中(注意不是codebehind頁面),則不需要再用import的方法引入了.
同樣道理,在asp.net 1.1中,自訂控制項的引用,在aspx頁面中也是很麻煩的,在asp.net 2.0中,可以在web.config中這樣定義
<%@Register TagPrefix="uc" Namespace="xxxxxx" Assembly="xx" %>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<pages>
<namespaces>
<add namespace ="System.IO" />
<add namespace="System.Text"/>
</namespaces>
<controls>
<add tagPrefix="uc" namespace="xx"
assembly="xxxx" />
</controls>
</pages>
</configuration>
</system.web>
這樣,在aspx頁面中,只需要用uc來引用就可以了,十分方便