ASP.NET postbacks lose the hash in the URL -
on asp.net page tabstrip, i'm using hash code in url keep track of tab i'm on (using bbq jquery plugin). example:
http://mysite.com/foo/home#tab=budget
unfortunately, i've realized there couple of places on page i'm using old-fashioned asp.net postback stuff, , when postback complete, hash gone:
http://mysite.com/foo/home
... i'm whisked away different tab. no good.
this webforms site (not mvc) using .net 4.0. can see, though, using url routing.
is there way tell asp.net keep hash in url following postback?
the problem postback goes url of current page, set in action of form on page. default url without #hash in asp.net, , automatically set asp.net, have no control on it.
you add #hash forms action attribute javascript:
document.getelementbyid("aspnetform").action += location.hash
or, if updating action hash in it:
var form = document.getelementbyid("aspnetform"); form.action = form.action.split('#')[0] + location.hash
just make sure execute code on window.load , target right id
Comments
Post a Comment