I was working with Devsaninii's answer where I changed the target of the form and found the undesired behavior of the rest of my pages switching to a new window after clicking a link that changed the target. Which made sense but was undesirable.
I was opening files with some links and loading new pages with others. I wanted the files to open in new windows and I wanted the new pages to open in the same window. But after I changed the target everything was in a new window. I could have gone through and added a client click handler to each and every linkbutton
, but that was too cumbersome.
So here is what I came up with:
I added a class to my linkbuttons
that were supposed to have a new window as the target and then I added this little piece of jQuery to my script:
$(function() {
$('a').click(function() {
if ($(this).hasClass('changeTarget')) {
window.document.forms[0].target = '_blank';
} else {
window.document.forms[0].target = '_self';
}
});
});
Now when a linkbutton
that should have a new window is pressed, it opens in a new window, and when anything else is pressed, it opens in the same window.
target="_blank"
. – AnchusinLinkButton
acts like aButton
control. Would you expect it to be able to facilitate this behavior? If it is absolutely necessary either use javascript or a hyperlink. – Tackle