0

I have an asp.net application, that onclick takes the user to a different part of the page. The onclick causes a postback, and when the page loads, the part of the page that I want to go to is set to display none

So, what I need to do is detect the presence of #apply in the URL.

This is proving more difficult than I would expect.

I have tried:

string path = HttpContext.Current.Request.RawUrl;
string path = HttpContext.Current.Request.Url.Fragment;

and every other option I could find, including the answer from Get part of a URL after domain using Regex, which I thought would work, although I used URL not uri.

Is it possible to do this?

1
  • URL encode the hashtag, it should post it back then Commented Nov 4, 2015 at 11:36

2 Answers 2

1

No. The hash URL fragment is not send to the server, so you can't access it. That part is just for client side purposes, so you only have access to it there.

Sign up to request clarification or add additional context in comments.

Comments

1

The #apply is used on the client only, so you can't access it server-side.

If you are using WebForms, this might help:

Page.MaintainScrollPositionOnPostback="true"

https://msdn.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpositiononpostback(v=vs.110).aspx

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.