Hisham Bin Ateya
Hisham Bin Ateya

Reputation: 1

UrlRouting for internal links

How can I use asp.net 4.0 routing scheme to navigate an internal links in other page

the original page is something like this about.aspx#CEO I tried a lot with about/CEO

no way!!

Upvotes: 0

Views: 412

Answers (1)

Aghilas Yakoub
Aghilas Yakoub

Reputation: 28990

You can read this - based on Page.GetRouteUrl method

Link : http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx

Link : http://msdn.microsoft.com/en-us/library/dd329551%28v=vs.100%29.aspx

In your Global.asax file

void Application_Start(object sender, EventArgs e)
{
    RegisterRoutes(RouteTable.Routes);
}

void RegisterRoutes(RouteCollection routes)
{
   routes.MapPageRoute("test", "about/CEO",  "~/about.aspx#CEO");
}

Use case

<asp:HyperLink ID="HyperLink2" runat="server" 
    NavigateUrl="~/about/CEO">
    Test
</asp:HyperLink>

Upvotes: 1

Related Questions