你好,我有一个页面提交的问题:left.aspx在框架A中,想点击Button时提交到框架B中的Main_Search.aspx 页面,我改变DropDownList1的值时就会提交页面,请帮帮我。谢谢。Left.aspx代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Left.aspx.cs" Inherits="Tel_Left" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server" target=“B" >
    <div>
        <asp:Label ID="Label1" runat="server" Text="Quick Search<br>
 快速查询"></asp:Label><br />
        <asp:DropDownList ID="DropDownList1" runat="server" 
            onselectedindexchanged="DropDownList1_SelectedIndexChanged" 
            AutoPostBack="true" Width="160px">
        <asp:ListItem Value="StaffNo" Text="Staff No.(工号)"></asp:ListItem>
        <asp:ListItem Value="Ext1" Text="Ext No.(内线号码)"></asp:ListItem>
        <asp:ListItem Value="cName" Text="Name(姓名-英文/拼音)"></asp:ListItem>
        <asp:ListItem Value="Dept" Text="Dept(部门)"></asp:ListItem>
        </asp:DropDownList><br />
        <asp:TextBox ID="TextBox1" runat="server" Width="160px" ></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            ErrorMessage="请输入查询的关键字" ControlToValidate="TextBox1" ></asp:RequiredFieldValidator><br />
        <asp:ListBox ID="ListBox1" runat="server" Visible="False" 
            onselectedindexchanged="ListBox1_SelectedIndexChanged" AutoPostBack="true" 
            Width="160px"></asp:ListBox><br />
       
        <asp:Button ID="Button1" runat="server" Text="Button"   onclick="Button1_Click1" />
        
    </div>
    </form>
</body>
</html>Left.aspx.cs 代码如下:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using MySql.Data.MySqlClient;public partial class Tel_Left : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Button2.Attributes.Add("OnClick","this.frame.target='tel_main'");
        //form1.Target = "tel_main";        string query = "select dept from tel group by dept";        MySqlConnection myConnection = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MySqlStr"].ConnectionString);
        MySqlCommand myCommand = new MySqlCommand(query, myConnection);
        myConnection.Open();        MySqlDataAdapter myDataAdapter =new MySqlDataAdapter(myCommand);
        DataTable myData = new DataTable();
        myDataAdapter.Fill(myData);
        if (!IsPostBack)
        {
            ListBox1.DataTextField = "Dept";
            ListBox1.DataValueField = "Dept";
            ListBox1.DataSource = myData;
            ListBox1.DataBind();
        }
        myConnection.Close();
    }    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
           switch (DropDownList1.SelectedValue)
            {
                case "Dept":
                    ListBox1.Visible = true;
                    TextBox1.Text = "";
                    break;
                default:
                    ListBox1.Visible = false;
                    TextBox1.Text = "";
                    break;
            }
        
    }    protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        TextBox1.Text = ListBox1.SelectedValue;
    }    protected void Button1_Click1(object sender, EventArgs e)
    {
        Server.Transfer("Main_Search.aspx");
    }
}

解决方案 »

  1.   

    left.aspx在框架A中,想点击Button时提交到框架B中的Main_Search.aspx 页面
    给left.aspx的form添加属性 action="Main_Search.aspx"我改变DropDownList1的值时就会提交页面
    把DropDownList1的autopostback设为true
      

  2.   

    Server.Transfer("Main_Search.aspx?str="+DropDownList1.SelectedValue);
      

  3.   

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
               switch (DropDownList1.SelectedValue)
                {
                    case "Dept":
                        ListBox1.Visible = true;
                        TextBox1.Text = "";
                        break;
                    default:
                        ListBox1.Visible = false;
                        TextBox1.Text = "";
                        break;
                }
            Server.Transfer("Main_Search.aspx");
        }
      

  4.   

    我不想改变DropDownList1值时提交页面,只想点击Button1时才提交页面。
      

  5.   

    如果做成无刷新,则TextBox1中的值不会变化啊,我想要DropDownList1变化时,TextBox1中的值也变化
      

  6.   

    DropDownList1 服务器控件改变值刷新页面很正常
    不刷新的话 用ajaxpanel吧 你那个查询功能ajaxpanel 都包起来就可以了