[英]Accessing Other Page Controls From This Page
Page 1 - Ticket.aspx
, DropDownList1
, ModalPopUpextender
with id mpe
1 -
Ticket.aspx
, DropDownList1
, ModalPopUpextender
ID为mpe
Page 2 - Customer.aspx
, btnSave
第2页-
Customer.aspx
, btnSave
The index change event of dropdown will pop up mpe
which has an iframe
. 下拉的指数变化情况,会弹出
mpe
它有一个iframe
。 This iframe
loads Customer.aspx
. 此
iframe
加载Customer.aspx
。
I am trying to access page1
controls in the button click event, but unable to. 我正在尝试在按钮单击事件中访问
page1
控件,但无法访问。
Customer.aspx.cs: Customer.aspx.cs:
protected void btnSave_Click()
{
Ticket page = new Ticket();
ModalPopUpExtender mpe = (ModalPopUpExtender)page.FindControl("mpe");
DropDownList ddl = (DropDownList)page.FindControl("DropDownList1");
//error here - Object reference not set to an instance
mpe.hide();
ddl.selectedindex=0;
}
Why is this not working. 为什么这不起作用。 Using a Session variable should work right?
使用Session变量应该正确吗?
You may use Server.Transefer instead of Response.Redirect and then you can find the control in the current page. 您可以使用Server.Transefer代替Response.Redirect,然后可以在当前页面中找到该控件。 Like:
喜欢:
TextBox tb = (TextBox)PreviousPage.FindControl("textbox1");
EDIT: 编辑:
if (Page.PreviousPage != null)
{
DropDownList ddl1 =
(DropDownList)Page.PreviousPage.FindControl("DropDownList1");
if (ddl1 != null)
{
Label1.Text = ddl1.SelectedItem.Text; //your logic
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.