用户response.redirect在新选项卡或窗口中打开链接

时间:2011-05-30 11:55:18

标签: asp.net

我想使用response.redirect在新窗口或标签页面中打开页面。我试过跟踪的事情。 1)

<asp:ImageButton ID="createPanelBtn" runat="server"  ImageUrl="~/Resources/User.ico"     Height="23px" ToolTip="Create Interviewer Panel" CommandName="createPanelBtn" 
 CommandArgument="  <%#((GridViewRow)Container).RowIndex %>" Width="20px"  OnClientClick="aspnetFrom.target='_blank';"/>

2)

Response.Write("<script>window.opem('~/HR  Administrator/ConfirmationEntryForm.aspx?VacId=" + strVacId + "&CompId=" + strCompId + "&DeptId=" + strDeptId+")'</script>");
Response.End();

在任何情况下,我都无法实现目标。请告诉我一些方法......

4 个答案:

答案 0 :(得分:2)

在你的问题中写点(2)的更好方法我建议使用文字控件。它是在网页上包含/排除脚本的最便宜和最简单的方法。喜欢例如说我有一个登录页面,用户必须输入他的凭据。如果他输入了错误的凭据,页面应该回发并发出警告消息。为此,我只需将包含脚本代码的文字控件设置为可见(Visble=True)。

   <asp:Literal ID="ltrlInvalidLogon" runat="server" Visible="false">
            <script type="text/javascript">
                alert('Invalid LogonID or Password provided.');
            </script>
        </asp:Literal>

答案 1 :(得分:0)

<asp:LinkButton ID="lnkbtnvd" runat="server" Text="View Details" OnClientClick="javascript:window.open('viewclient.aspx', 'windowname', 'width=400,height=200,scrollbars=yes');" ></asp:LinkButton>

使用参数

答案 2 :(得分:0)

<asp:ImageButton id="createPanelBtn" runat="server" OnClientClick="javascript:window.open('page.aspx?ruerystring', 'windowname', 'width=600,height=600,scrollbars=yes');" />

和window.open函数的其他参数检查链接

http://www.w3schools.com/jsref/met_win_open.asp

http://www.javascript-coder.com/window-popup/javascript-window-open.phtml

答案 3 :(得分:0)

我找到了一个完美的解决方案!这是一种解决方法,但对我有用。

设置打开新时代的按钮的onclientclick属性,如下所示:

onclientclick =“window.document.forms [0] .target ='_ blank'; setTimeout(function(){window.document.forms [0] .target ='';},500);”

它使用setTimeout将更改恢复为原来的状态!

希望这可以帮助别人!

相关问题