【发布时间】:2012-09-12 14:41:05
【问题描述】:
我需要能够在 ASP .Net Webforms 中动态地在我的网页中设置链接。我知道您可以在 ASP .Net 中动态设置路由。
我也想以与 ASP .Net MVC 中的 UrlHelper 类似的方式从 RouteCollection 生成 Url。到目前为止,我找不到任何说明是否可以将 ASP .Net MVC 中的 UrlHelper 与 Webforms 一起使用。
【问题讨论】:
我需要能够在 ASP .Net Webforms 中动态地在我的网页中设置链接。我知道您可以在 ASP .Net 中动态设置路由。
我也想以与 ASP .Net MVC 中的 UrlHelper 类似的方式从 RouteCollection 生成 Url。到目前为止,我找不到任何说明是否可以将 ASP .Net MVC 中的 UrlHelper 与 Webforms 一起使用。
【问题讨论】:
您可能对Scott Hanselman recently blogged about和introduced in this blog post中的FriendlyUrls Nuget package感兴趣。
代码示例:
<a href='<%# FriendlyUrl.Href("~/WebForms/Edit", Item.TouristAttractionId ) %>'>Edit</a>
【讨论】: