【发布时间】:2020-01-13 19:08:10
【问题描述】:
希望你们都做得很好! 我的任务是单击按钮在新选项卡中打开页面。 让我证明一下,
<asp:Button runat="server" ID="btnCreateQuestion" Text="Create Question" CssClass="btn btn-primary" OnClick="btnCreateQuestion_OnClick" OnClientClick="SetTarget();" />
function SetTarget() {
debugger;
document.forms[0].target = "_blank";
}
protected void btnCreateQuestion_OnClick(object sender, EventArgs e) {
// other code ....
switch (questionType) {
case "Multiple Choice":
Response.Cookies["options"].Value = optionNumber;
Response.Redirect("~/Products/McQType.aspx?scode=" + subjectcodeid);
break;
}
}
现在此代码按预期工作,即页面正在新选项卡中打开...
现在我有一个网格,在该网格内我有一个按钮,它负责相同的功能,即在新选项卡中打开页面..
//button located inside grid
<asp:LinkButton CssClass="btn" ID="btnEditQuestion" runat="server"
Style="padding-right: 10px; font-size: 11px; letter-spacing: -0.1px; font-family: Arial,Helvetica,sans-serif !important; font-weight: bold !important;"
OnClick="btnEditQuestion_OnClick"
OnClientClick="SetTarget();">
Edit Question
<i class="fa fa-edit" aria-hidden="true"></i>
</asp:LinkButton>
protected void btnEditQuestion_OnClick(object sender, EventArgs e) {
{
case "Multiple Choice":
Response.Redirect("~/Products/McQType.aspx?qid=" + questionId);
break;
}
}
现在页面正在打开但不在新标签中,它应该在新标签中打开..
如何解决这个问题?
【问题讨论】: