【发布时间】:2010-11-21 10:29:31
【问题描述】:
我有一种情况,我想在我的 ScriptManager(包含在我的 MasterPage 中)中引用的 js 文件(例如“custom.js?2009082020091417”)的路径中添加“上次修改”时间戳并在任何 ScriptManagerProxies(内容页面)中。
我可以轻松地在代码中访问 ScriptManager,然后遍历它的 Scripts 集合以获取我以声明方式设置的脚本路径,然后“设置”一个带有“?[lastmodifiedtimestamp]”的新路径。
问题是,我不知道如何访问可能存在的任何 ScriptManagerProxies。
调试时,我可以看到非公共成员(._proxies)中的代理。我浏览了文档,但看不到您可以在哪里实际公开访问此集合。
我错过了什么吗?
我的内容页面的 Page_PreRenderComplete 事件的基类中有以下代码:
ScriptManager sm = ScriptManager.GetCurrent((Page)this);
if(sm != null)
{
foreach (ScriptReference sr in sm.Scripts)
{
string fullpath = Server.MapPath(sr.Path);
sr.PathWithVersion(fullpath); //extension method that sets "new" script path
}
}
上面的代码提供了我在 MasterPage 中定义的一个脚本,但没有提供我在内容页面的 ScriptManagerProxy 中定义的另外两个脚本。
【问题讨论】:
标签: asp.net javascript asp.net-ajax auto-versioning