你好,我有一个页面提交的问题: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");
}
}
<%@ 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");
}
}
解决方案 »
- WebBrowser怎样捕捉VML地图的截图?
- 大家帮我看看我的简历,要怎样写比较好。
- 如何将IP地址后面的三位或二位替换?
- 开发asp.net必须在装有2000server的机子上吗,我公司以前的网站是否支持啊。
- 专家请帮忙~asp.net中调用JavaScript的错误
- 我怎么能够取到别的网站里面的内容,放在我们自已的网站里面
- 求一算法的问题
- aspx的异步请求得不到服务器控件的值
- 水晶报表问题
- 思归(saucer)大侠等高手请进来看一下,谢谢!
- gridview怎样在网页里写deletecommand,updatecommand
- gridview用div滚动条,当gridview资料多时候带滚动条,选中行编辑时重新定位,如何解决。
给left.aspx的form添加属性 action="Main_Search.aspx"我改变DropDownList1的值时就会提交页面
把DropDownList1的autopostback设为true
{
switch (DropDownList1.SelectedValue)
{
case "Dept":
ListBox1.Visible = true;
TextBox1.Text = "";
break;
default:
ListBox1.Visible = false;
TextBox1.Text = "";
break;
}
Server.Transfer("Main_Search.aspx");
}
不刷新的话 用ajaxpanel吧 你那个查询功能ajaxpanel 都包起来就可以了