C# Target=“_blank” in a LinkButton

前端 未结 8 1332
无人及你
无人及你 2020-12-06 00:58

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



        
相关标签:
8条回答
  • 2020-12-06 01:49

    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>
    
    0 讨论(0)
  • 2020-12-06 01:51

    After looking at these answers and none was exactly what I wanted (do this with a button look), I ended up using a hyperlink control, but used the same css style as my regular buttons:

    .button {
    
        background-color:#011745;
        color:white;
        padding:7px 12px 7px 12px;
        margin:3px;
        border-style:none;
        font-size:12px;
    
    }
    
    .button:hover {
    
        background-color:#336699;
        color:white;
        padding:7px 12px 7px 12px;
        margin:3px;
        border-style:none;
        font-size:12px;
    
    }
    

    It looked just like them! If you are going for a button that opens a link in a new window, which I was, it was almost perfect. In a set of table cells, it displayed just a touch lower than the regular buttons, so I styled it like this: "position:relative; top:-2px;" and that did the trick. I also had to force the forecolor white:

    <asp:HyperLink ID="btnSummaryReport" Target="_blank" runat="server" Text="SUMMARY REPORT" CssClass="button" ForeColor="white" Font-Size="8" style="position:relative; top:-2px" />
    
    0 讨论(0)
提交回复
热议问题