Infragistics for asp.net套件其功能很强大,做局域网中的web系统很方便,为什么建议用在局域网中呢,因为它的性能很成问题,一个页面返回到客户端,文件会很大,需要更大的带宽。因其控件的复杂性,设置每个控件的样式CSS是比较困难的,因此Infragistics 公司有自己的一套样式管理方案。主要使用AppStylist for ASP.NET来配置和管理一个样式库。你可以启动AppStylist for ASP.NET打开他的例子库看一下,所有可视控件的样式都可以控制,这个工具配置好后,会生成一个文件夹,下边有所有控件对应的css文件和相关资源。现在就可以在我们的web应用上使用这种风格,可以做成固定的方式,或者由用户自己定制。
第一种使用方式:使用母板页来控制
只要在母板页中放一个WebPageStyler控件,可以先指定好StyleSetPath和StyleSetName
<igmisc:WebPageStyler ID="WebPageStylerMaster" runat="server"
EnableAppStyling="True" StyleSetName="Appletini" StyleSetPath="" />
也可以在代码中动态配置
if (!IsPostBack)
{
//设置所有Infragistics控件的样式
WebPageStylerMaster.StyleSetPath = MyConfiguration.InfragisticsStyleLibrary;
WebPageStylerMaster.StyleSetName = MyConfiguration.InfragisticsStyleName;
//Response.Write(WebPageStylerMaster.StyleSetPath);
}
//MyConfiguration类实现
public static class MyConfiguration
{
private static string _InfragisticsStyleLibrary;
private static string _InfragisticsStyleName;
#region
/// <summary>
/// Infragistics控件样式库位置
/// </summary>
/// <param name="Session"></param>
/// <returns></returns>
public static string InfragisticsStyleLibrary
{
get
{
if (string.IsNullOrEmpty(_InfragisticsStyleLibrary))
{
//从web.config中取得系统默认值
Hashtable ht = (Hashtable)ConfigurationManager.GetSection("infragistics.web");
_InfragisticsStyleLibrary = ht["styleSetPath"].ToString();
}
return _InfragisticsStyleLibrary;
}
}
/// <summary>
/// Infragistics样式库,当前用户使用的样式名
/// </summary>
/// <param name="Session"></param>
/// <returns></returns>
public static string InfragisticsStyleName
{
get
{
if (string.IsNullOrEmpty(_InfragisticsStyleName))
{
//从web.config中取得系统默认值
Hashtable ht = (Hashtable)ConfigurationManager.GetSection("infragistics.web");
_InfragisticsStyleName = ht["styleSetName"].ToString();
}
return _InfragisticsStyleName;
}
}
#endregion
}
//web.config配置部分
<configSections>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
<section name="infragistics.web" type="System.Configuration.SingleTagSectionHandler,System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</sectionGroup>
</configSections>
<!--默认的Infragistics控件的样式库文件全路径,本地路径和URL
-->
<infragistics.web styleSetName="Default" styleSetPath="http://localhost/StyleLibrary"/>
http://localhost/StyleLibrary 是个虚拟目录,指向AppStylist for ASP.NET配置好的目录,可以放到不同的站点上
这样母板页就设置好了,其它内容页面中如果有Infragistics控件会自动的应用母板页设置好的风格
第二种方式:直接在页面中设置每个控件的样式库
以为UltraWebGrid为例子,其它控件一样的方法
maingrid.StyleSetPath = MyConfiguration.InfragisticsStyleLibrary;
maingrid.StyleSetName = MyConfiguration.InfragisticsStyleName;
maingrid.EnableAppStyling = Infragistics.WebUI.Shared.DefaultableBoolean.True;