Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to formulate a MapPageRoute with a hash (#) in it?

I'm using MapPageRoute to make a route to a page, which works fine. However, I would like the page to scroll to the bottom to show a certain div with id bottom. I have tried to make the following route but the hash is being encoded in the URL so the page does not scroll down.

RouteTable.Routes.MapPageRoute("Topics", 
 "onderwerpen/{ID}/{name}#bottom", 
 "~/TopicPage.aspx"
);

results in:

mydomain/onderwerpen/1/title%23bottom

when called like this:

Response.RedirectToRoute("Topics", new { ID = 1, name = "title" });
like image 455
Bazzz Avatar asked Dec 06 '25 03:12

Bazzz


1 Answers

I think I found the most suitable solution myself. This answer is open for discussion.

string url = Page.GetRouteUrl("Topics", new { ID = 1, name = "title" });
Response.Redirect(url + "#bottom");
like image 159
Bazzz Avatar answered Dec 08 '25 18:12

Bazzz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!