asp.net通过传递查询字符串重定向NEW TAB中的下拉列表中的页面onselectedindexchanged

时间:2013-09-03 12:55:26

标签: c# javascript asp.net

这是我的代码。 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);



    }

1 个答案:

答案 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);
    }