I've got some pages that may or may not load with a ReturnUrl parameter, and some links that will be generated without that parameter (though I've applied a class to them).
The site uses jQuery, and I think I've found the most elegant and least breaky solution as follows:
$(document).ready(function() {
$('a.my_returnlink').each(function(){
$(this).attr('href',$(this).attr('href')+window.location.search);
});
});
That is, given a page url like http://example.com/page.aspx?ReturnUrl=blahblahblah
and the following link on the page: <a class="my_returnlink" href="http://example.com/someotherpage.aspx">Some link</a>
, that link will end up pointing to http://example.com/someotherpage.aspx?ReturnUrl=blahblahblah
.
Is there any reason not to do it this way?