我使用的是VS.NET 2005,C#,我无法在第二个页面上使用第一个页面的控件参数。譬如在第一个页面search1上我定义了一个RadioButtonList1,想将它传递到第二个页面search2上,我是这么写的:search1页面:<html>
<body>
<form id="form1" method="post" action="search2.aspx" runat="server"> <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" DataSourceID ="对机组类型表的绑定" DataValueField="机组类型" Style="position: static" Width="132px" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
</asp:RadioButtonList> </form>
</body>
</html>search2页面的cs代码(在此页面定义了一个label5):public partial class search2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
label5 = string.Format(search1.RadioButtonList1.SelectedValue);
}
}但是在编译时说是无法找到search1,是不是单纯地用form提交这种方法不可行,请问我该怎么调用它呀?
<body>
<form id="form1" method="post" action="search2.aspx" runat="server"> <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" DataSourceID ="对机组类型表的绑定" DataValueField="机组类型" Style="position: static" Width="132px" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
</asp:RadioButtonList> </form>
</body>
</html>search2页面的cs代码(在此页面定义了一个label5):public partial class search2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
label5 = string.Format(search1.RadioButtonList1.SelectedValue);
}
}但是在编译时说是无法找到search1,是不是单纯地用form提交这种方法不可行,请问我该怎么调用它呀?
解决方案 »
- asp.net 中button 如何让它显示与不显示
- DataGrid中加一列CheckBox,删除选中行!已有部分代码.
- 求助关于.net的问题!~
- 用label显示一个文字,当文字大了,就会出现文字上部显示不全的问题,我把label高度设高也不行,该如何解决呢?
- 两个.aspx页面下的HTML中如何传递参数。
- c#中如何调用vb写的类
- asp.net里能调用.net自动产生的代理类中的异步调用方法吗?请大虾指教
- 求救
- 来者有分,请问几个.NET的问题:
- GridView字符或者日期列居左显示,数字列居右显示
- 如何控制DataList显示格式
- 200分相送,有谁曾经试图自己实现分层数据源控件吗?
{
protected void Page_Load(object sender, EventArgs e)
{
label5.Text = string.Format(Request["RadioButtonList1"]);
}
}
<asp:TextBox ID="TextBox1" runat="server">hi</asp:TextBox>
<asp:Button ID="Button1" runat="server" PostBackUrl="WelcomeWorld.aspx" Text="Button" />第2个页面 WelcomeWorld.aspx:
if (Page.PreviousPage != null)
{
this.Label1.Text = "hello <br>" + ((TextBox)Page.PreviousPage.FindControl("TextBox1")).Text;
}
则读到 第一个页面 的 ID="TextBox1" 的 值
a.html<script>
var a;
</script>
<a href="b.html" target="_blank">a</a>
<div id=test></div>b.html
<script>
function setvalue(){
window.opener.document.a="b"//该值可改为由数据库获得
window.opener.document.getElementById("test").innerHTML="由数据库获得"
}
</script>
<body>
<input onclick=setvalue() type=button>
</body>
<body>
<form id="form1" method="post" runat="server"> <asp:RadioButtonList ID="RadioButtonList1" runat="server" DataSourceID ="对机组类型表的绑定" DataValueField="机组类型" Style="position: static" Width="132px" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
</asp:RadioButtonList> <asp:button id="button1" runat="server" postbackurl="searc2.aspx" text="submit"/>
</form>
</body>
</html>search2页面的cs代码(在此页面定义了一个label5):public partial class search2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
RadioButtonList ctl = this.PreviousPage.FindControl("RadioButtonList1") as RadioButtonList;
if (ctl != null) label5.Text = ctl.SelectedValue;
}
}
第一个页面
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" DataSourceID ="对机组类型表的绑定" DataValueField="机组类型" Style="position: static" Width="132px" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
</asp:RadioButtonList>
<asp:Button ID="Button1" runat="server" PostBackUrl="WelcomeWorld.aspx" Text="Button" />search2页面的cs代码(在此页面定义了一个label5):public partial class search2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
label5.Text = string.Format(Request["RadioButtonList1"]);
}
}