这是我的代码。 Plz帮我在新标签页面中重定向页面。 它可以是脚本或c#代码。 提前谢谢。
<asp:DropDownList ID="ddlcomplaint" CssClass="list-item-width1" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddlcomplaint_SelectedIndexChanged" onchange="aspnetForm.target ='_blank';">
protected void ddlcomplaint_SelectedIndexChanged(object sender, EventArgs e)
{
txtTitle.Text = "";
int complaint = Convert.ToInt16(ddlcomplaint.SelectedValue);
if (complaint == 100)
{
txtTitle.Enabled = true;
}
else
{
txtTitle.Enabled = true;
txtTitle.Text = ddlcomplaint.SelectedItem.Text.ToString();
}
string Title = ddlcomplaint.SelectedItem.Text;
Response.Redirect("/SearchComplaint.aspx?Title=" + Title);
}
答案 0 :(得分:0)
<强>的JavaScript 强>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function Redirect() {
var ddl1 = document.getElementById('<%= ddlcomplaint.ClientID %>');
var selectedval = ddl1.options[ddl1.selectedIndex].value;
window.open("/SearchComplaint.aspx?Title=" + selectedval );
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddl1" runat="server" onchange="Redirect();">
</asp:DropDownList>
</div>
</form>
</body>
</html>
或
<强> c#中强>
protected void ddl1_SelectedIndexChanged(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(),"OpenWindow","window.open('/SearchComplaint.aspx?Title=" + Title');",true);
}