Search code examples
c#targetlinkbutton

C# Target="_blank" in a LinkButton


is it possible to have a target="_blank" in LinkButton...mine doesnt seem to be working

<asp:LinkButton runat="server" ID="g31" Text="PDF" 
    CommandArgument='<%# DataBinder.Eval(Container.DataItem,"productID") %>'
    CommandName='<%# DataBinder.Eval(Container.DataItem,"documentID") %>'
    OnCommand="linkbutton_showpdf" target="_blank">
</asp:LinkButton>

Or would I have to use a different button format?


Solution

  • Just render an anchor with href set to appropriate url and set the target attribute to _blank it will open the url into new window.

    <a href="urlOfThePage" target="_blank" >Click me</a>