不同页面之间传递值(使用Page.PreviousPage.FindControl)
来源:互联网 发布:excel数据列转行 编辑:程序博客网 时间:2024/05/29 04:44
这个场景太常见了,当然有许多许多的方法,我来介绍一种非常简单的方法吧!
第一步:模拟两个页面
A页面、B页面。需要在B页面获取A页面的信息。
A页面:
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
<asp:Button ID="Button1" runat="server"
PostBackUrl="~/B.aspx" Text="Button" />
</form>
B页面:
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<a href="A.aspx">A.aspx</a>
</form>
第二步:如何获取呢
来个非常简单的,在B页面Page_Load事件中使用Page.PreviousPage 属性,获取向当前页传输控件的页。 找到相应的控件。
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) {
TextBox t = ((TextBox)(PreviousPage.FindControl("Textbox1")));
Calendar c = ((Calendar)(PreviousPage.FindControl("Calendar1")));
Label1.Text = string.Format("文本框:{0},选择日期?:{1}",
t.Text, c.SelectedDate);
}
}
- 不同页面之间传递值(使用Page.PreviousPage.FindControl)
- 不同页面之间传递值——Page.PreviousPage 属性
- 不同页面之间传递值
- asp.net中的跨页发送(利用PreviousPage.FindControl()方法取值)
- Page.FindControl
- 当PreviousPage.FindControl遇到MasterPage,如何查找控件?
- this.PreviousPage.FindControl遇到MasterPage,如何查找控件?
- 在不同页面之间传递参数
- 两个不同HTML页面之间参数传递
- 页面之间传递值
- 页面之间传递值
- 页面之间值传递
- 使用PreviousPage对象在网页间传递Web窗体内容
- Page.PreviousPage System.Threading.ThreadAbortException
- 使用session在不同页面之间传递参数,sqldatasource按条件查询
- 页面间传值用PreviousPage方法
- 使用PreviousPage来获取前一页页面的元素
- Page.FindControl找不到控件
- 拦截器
- ASP.Net生成后台脚本的问题的解决办法
- 在跨平台的C++程序中使用OTL来操作不同的数据库
- SQL 循环及 字符串转换
- auto、register、static、extern等存储类修饰符的区别
- 不同页面之间传递值(使用Page.PreviousPage.FindControl)
- ASP.NET MVC 入门1、简介
- 夯实安全管理基础 提高电网运行水平123
- MySQL系统变量interactive_timeout 与 wait_timeout
- 3种后台生成前台脚本的方法
- VC++下编译出极小的程序
- AOP和AspectJ
- jquery 系列 一,简介
- 渐渐成熟的十五种迹象