views:

174

answers:

1

Opposite of this question: Retain anchor after postback in asp.net

I'm having the issue that on postback, it's keeping an anchor.

I'm starting in Browse.aspx; user clicks something which takes them to an anchor on the page. They then choose a new filter from DropDownList, so it refreshes back to page 1 with the filter in place, but the anchor stays in the url causing them to jump down the page.

I tried added PostBackUrl="~/Browse.aspx" attribute to the DropDownList to no avail.

Any ideas?

Note, I'm sending them to the anchor with he following method in code behind:

    RegisterStartupScript("navigateto", "<script type='text/javascript'>document.location.href='#photo1';</script>");
+1  A: 

I think you'll have to do a server.redirect (or inject another client script that refreshes the page) when the user chooses a new filter, without the anchor in the url. The browser on its own will not lose it during post-backs.

cdonner
No cleaner way to do it :-/That would work I suppose, was hoping not to have to do something like that.
Aequitarum Custos