简体   繁体   English

Asp.net WebForm-在标记中使用RouteUrl

[英]Asp.net WebForm - Using RouteUrl in Markup

I try use syntax shown in this Post but I still getting errors like: 我尝试使用此所示语法帖子 ,但我仍然得到这样的错误:

Invalid expression, RouteUrlExpressionBuilder expects a string with format: RouteName=route,Key1=Value1,Key2=Value2. 无效的表达式,RouteUrlExpressionBuilder期望使用以下格式的字符串:RouteName = route,Key1 = Value1,Key2 = Value2。

My route and link are: 我的路线和链接是:

routes.MapPageRoute("about", "about/", "~/About.aspx");

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="<%$RouteUrl:about%>">About</asp:HyperLink>

Could u tell my what I doing wrong? 你能告诉我我做错了什么吗?

As error mentioned, we need to have register some thing like this 如错误所述,我们需要注册一些类似的东西

routes.MapPageRoute(
                "about",
                "about/{Name}",
                "~/About.aspx"
            );

Then master page should be like: 然后母版页应类似于:

<asp:MenuItem NavigateUrl="<%$RouteUrl:Name=Test %>" Text="About" /> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM