A common scenario here is that we have a button (or link) that when clicked we want some server code to fire but at the end of the request we actually want to display the content in a new window.
At first we might think that an easy way to do this is to use an ASP.NET LinkButton to do this - after all a LinkButton creates a hyperlink that CAN accept a target and it also posts back to the server, right? However, there's no Target property, although you can set the target HTML attribute easily enough.
<asp:LinkButton runat="server" ID="btnTest" Text="New Target"
target="_blank" OnClick="btnTest _Click" />
But if you try this you'll find that it doesn't work. Why? Because ASP.NET creates postbacks with JavaScript code that operates on the current window/frame:
Solution: In order to send Postback link controls and buttons to another window/frame, both require that the target of the form gets changed dynamically when the button or link is clicked. You can use jQuery for changing the forms target.
Imagine you have two buttons like this that should go to another window:
<asp:LinkButton runat="server" ID="lnkTest" Text="New Target"
OnClick="ClickHandler" />
<asp:Button runat="server" ID="btnTest" Text="New Target Button"
Join the conversation! Your thoughts help the community grow.