关于设置WebControls里的treeview控件的图片路径
2007-09-30 13:42
627 查看
一般我们使用这个treeview控件时都是在虚拟目录下复制webctrl_client目录到默认网站的根目录下,其实这对开发人员只是很简单的一个步骤,但是在打包部署的时候确碰到了问题,假设你的网站是安装在虚拟目录下,你怎么使你的安装程序自动复制这个目录到相应的地方去呢,这是个问题
.于是google,下载了http://www.microsoft.com/china/MSDN/library/archives/library/DNAspp/html/aspnet-usingtreeviewieWebcontrol.asp里wencontrols的代码并安装,查看treeview.cs,终于找到主要是AddPathToFilename这个函数来控制目录得,而这个函数在BaseRichControl.cs的抽象类里定义
// --------------------------------------------------------------------
// Common Files
// --------------------------------------------------------------------
/**//// <summary>
/// Adds the common file path to the filename.
/// </summary>
/// <param name="filename">The filename to qualify with the common path.</param>
/// <returns>The full path of the filename with the common path.</returns>
protected string AddPathToFilename(string filename)
{
return AddPathToFilename(Context, filename);
}
/**//// <summary>
/// Static version of AddPathToFilename so that classes not deriving from
/// BaseRichControl can still find the common files path.
/// </summary>
/// <param name="context">The context from which to get the configuration.</param>
/// <param name="filename">The filename to qualify with the common path.</param>
/// <returns>The full path of the filename with the common path.</returns>
internal static string AddPathToFilename(HttpContext context, string filename)
{
return FindCommonPath(context) + filename;
}
/**//// <summary>
/// Finds the path for client files used be server controls.
/// </summary>
/// <param name="context">The context from which to get the configuration.</param>
/// <returns>The path name.</returns>
private static string FindCommonPath(HttpContext context)
{
// Look at the current configuration for the path
if (context != null)
{
NameValueCollection table = (NameValueCollection)context.GetConfig(ConfigName);
if (table != null)
{
string path = (string)table[CommonFilesKey];
if (path != null)
{
return CleanupPath(path);
}
}
}
// Return the default path with version number
Assembly assembly = typeof(BaseRichControl).Assembly;
Version version = assembly.GetName().Version;
return DefaultCommonFilesRoot + version.Major.ToString() + "_" + version.Minor.ToString() + "/";
}
,本来开始的想法是改这个函数,后来发现其实它还有个可配置的路径接口,还是先配置吧!
于是在web.config加入以下节
<configSections>
<section name="MicrosoftWebControls" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<MicrosoftWebControls>
<add key="CommonFiles" value="/web/treepath/"></add>
</MicrosoftWebControls>
注意:configSections一定要放在第一个子节最前面.
剪切默认网站的webctrl_client目录到虚拟目录web/treepath/下,运行程序,
树型界面出现了,只是前面的加减号出现问题,再右键查看WEB代码,发现SystemImagesPath属性还是指到webctrl_client目录下,看了SystemImagesPath的代码,把treeview控件的SystemImagesPath设置为空,再次运行程序,OK!全部通过,treeview的图片目录再也不需要依赖默认网站的图片目录了,打包也变的方便了,如果是几个网站在一个机器上,你也可以设置自己独立的treeview图片风格了,嘿嘿,再此写下这些供大家参考
.于是google,下载了http://www.microsoft.com/china/MSDN/library/archives/library/DNAspp/html/aspnet-usingtreeviewieWebcontrol.asp里wencontrols的代码并安装,查看treeview.cs,终于找到主要是AddPathToFilename这个函数来控制目录得,而这个函数在BaseRichControl.cs的抽象类里定义
// --------------------------------------------------------------------
// Common Files
// --------------------------------------------------------------------
/**//// <summary>
/// Adds the common file path to the filename.
/// </summary>
/// <param name="filename">The filename to qualify with the common path.</param>
/// <returns>The full path of the filename with the common path.</returns>
protected string AddPathToFilename(string filename)
{
return AddPathToFilename(Context, filename);
}
/**//// <summary>
/// Static version of AddPathToFilename so that classes not deriving from
/// BaseRichControl can still find the common files path.
/// </summary>
/// <param name="context">The context from which to get the configuration.</param>
/// <param name="filename">The filename to qualify with the common path.</param>
/// <returns>The full path of the filename with the common path.</returns>
internal static string AddPathToFilename(HttpContext context, string filename)
{
return FindCommonPath(context) + filename;
}
/**//// <summary>
/// Finds the path for client files used be server controls.
/// </summary>
/// <param name="context">The context from which to get the configuration.</param>
/// <returns>The path name.</returns>
private static string FindCommonPath(HttpContext context)
{
// Look at the current configuration for the path
if (context != null)
{
NameValueCollection table = (NameValueCollection)context.GetConfig(ConfigName);
if (table != null)
{
string path = (string)table[CommonFilesKey];
if (path != null)
{
return CleanupPath(path);
}
}
}
// Return the default path with version number
Assembly assembly = typeof(BaseRichControl).Assembly;
Version version = assembly.GetName().Version;
return DefaultCommonFilesRoot + version.Major.ToString() + "_" + version.Minor.ToString() + "/";
}
,本来开始的想法是改这个函数,后来发现其实它还有个可配置的路径接口,还是先配置吧!
于是在web.config加入以下节
<configSections>
<section name="MicrosoftWebControls" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<MicrosoftWebControls>
<add key="CommonFiles" value="/web/treepath/"></add>
</MicrosoftWebControls>
注意:configSections一定要放在第一个子节最前面.
剪切默认网站的webctrl_client目录到虚拟目录web/treepath/下,运行程序,
树型界面出现了,只是前面的加减号出现问题,再右键查看WEB代码,发现SystemImagesPath属性还是指到webctrl_client目录下,看了SystemImagesPath的代码,把treeview控件的SystemImagesPath设置为空,再次运行程序,OK!全部通过,treeview的图片目录再也不需要依赖默认网站的图片目录了,打包也变的方便了,如果是几个网站在一个机器上,你也可以设置自己独立的treeview图片风格了,嘿嘿,再此写下这些供大家参考
相关文章推荐
- 关于设置WebControls里的treeview控件的图片路径(转)
- 关于设置WebControls里的treeview控件的图片路径
- 关于设置WebControls里的treeview控件的图片路径
- 如何设置C# treeview Web控件背景图片
- 如何设置C# treeview Web控件背景图片
- 关于在.net中预览上传控件中路径的图片的方法
- 关于web项目图片路径问题
- 关于webpack打包图片的路径问题
- 分析器错误信息: 基类包括字段“TreeView1”,但其类型(Microsoft.Web.UI.WebControls.TreeView)与控件(Microsoft.Web.UI.WebControls.TreeView)的类型不兼容。
- 关于web项目中的图片上传、并在前端显示问题(tomcat中配置文件上传虚拟路径)
- 菜鸟的又一小小分享--关于用户控件中图片地址路径的问题
- 关于QT利用setStyleSheet为主控件添加背景图片,而不影响其子控件的背景设置
- [C#]使用 C# 代码实现拓扑排序 dotNet Core WEB程序使用 Nginx反向代理 C#里面获得应用程序的当前路径 关于Nginx设置端口号,在Asp.net 获取不到的,解决办法 .Net程序员 初学Ubuntu ,配置Nignix 夜深了,写了个JQuery的省市区三级级联效果
- ASP.NET用户控件中的图片路径如何设置,img相对路径设置方法
- 关于web中图片来源设置问题
- 关于在.net中 预览上传控件中路径的图片 的方法
- 关于用Webpack路径压缩图片上传尺寸获取的问题
- java web项目 图片资源与部署目录分离,设置服务器的虚拟路径
- 关于设置了LayoutAlgorithm.SINGLE_COLUMN后,某些手机的webview仍然无法适配图片的解决方案
- android中获取webview所有图片路径