简体   繁体   中英

How to open an url in new tab using a button in vb.net which using command name not by the click event

I am trying the open url using a button . But in this case i'm not using button click event, I am using the commandname to right code behind for the url. I can goto the url but it is happening in the same tab but i want it to open in a new tab. here is the button i'm using

  <asp:Button ID="btneditinformation" runat="server" CommandName="editinformation" CausesValidation="false" ToolTip="Edit information in QuickBase" Text="Edit Information" Height="30px" Width="100px" OnClientClick="aspnetForm.target ='_blank';"></asp:Button> 

and this is the code behind i am trying to use

 ElseIf e.CommandName = "editinformation" Then

        Response.Redirect(url)
    End If

Thanks in advance

服务器返回响应后,您将必须使用脚本管理器来帮助您执行javascript:

ScriptManager.RegisterStartupScript(Page, typeof(Page), "NewWindow", "window.open('" + url + "');", true);

There are two approach:

  1. you can do the same by jquery

      $("#btneditinformation").click(function () { window.open("URL","_blank") }) 
  2. You can use anchor tag with giving proper css class for button.

    <a class="btn btn-success" target="_blank" href="#">Link</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM