让母版页标签显示正在显示的子页面的最后编辑日期
我正在构建一个带有母版页的 asp.net 站点。当访问者查看页面时,我想显示子页面上次更新的日期和时间。我还想在母版页级别完成这一切,因此不需要将用于获取此信息的代码添加到每个子页面。
这可能吗?最好的方法是什么?
提前谢谢您!
i'm building an asp.net site with master pages. When visitors views a page, I'd like to show the date and time the child page was last updated. I'd also like to do this all at the master page level so no code for getting this information needs to be added to each child page.
Is this possible? what would be the best way to do it?
Thank you in advanced!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Page.Request.PhysicalPath
将为您提供页面的物理路径。FileInfo
类可用于获取其最后更新日期。如果您使用
Server.Execute
或Server.Transfer
进行重定向,则需要注意一些事项,在这种情况下,有多种替代方法可以实现此目的,包括 HttpRequest.PhysicalPath 的 MSDN 文档的备注部分。Page.Request.PhysicalPath
will give you the physical path of the page.And the
FileInfo
class can be used to get its last update date.There are caveats if you are redirecting using
Server.Execute
orServer.Transfer
, in which case there are several alternative ways of doing this, including the one described in the Remarks section of the MSDN documentation for HttpRequest.PhysicalPath.通常,这就是我放入
*_master.vb
代码隐藏文件中的内容。我使用具有Public LastUpdate As DateTime
属性的 MainMaster.vb 基类。Typically, this is what I put in my
*_master.vb
code-behind files. And I use a base MainMaster.vb class with thePublic LastUpdate As DateTime
property.