c# - 如何通过iframe获取另一个页面的asp隐藏字段值

标签 c# javascript jquery asp.net

我正在使用 C# 在 ASP.NET 中开发一个应用程序。在我的应用程序中,有两个页面,例如 abc.aspxxyz.aspx。我正在 abc.aspxiframe 中打开 xyz.aspx 页面。

xyz.aspx页面中,我有一个名为ht_test_access的asp隐藏字段。现在我的要求是我必须直接从 abc.aspx 访问该隐藏字段的值,而不需要查询字符串、 session 、cookie 等。请帮忙。

最佳答案

您可以使用Button.PostBackUrl并使用Page.PreviousPage获取上一页表单数据。这篇 MSDN 文章 Cross-Page Posting in ASP.NET Web Pages解释得很好。

string text = ((HiddenField)PreviousPage.FindControl("hdnField")).Value;

Cross-page posting is similar to hyperlinks in that the transfer is initiated by a user action. However, in cross-page posting, the target page is invoked using an HTTP POST command, which sends the values of controls on the source page to the target page. In addition, if the source and target page are in the same Web application, the target page can access public properties of the source page. As always, all of the pages in the application can share information stored in session state or application state.

关于c# - 如何通过iframe获取另一个页面的asp隐藏字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24300237/

相关文章:

c# - 升级到 .NET Core 1.1.1 后,ASP.NET Core MVC 应用程序洞察力停止工作

c# - 帮助正则表达式

javascript - 使光标悬停区域变大

javascript - 高分子简单元件

javascript - 按钮事件监听器无响应

javascript - Javascript 中值列表的动态验证

c# - 切换枪支

c# - LinkBut​​ton OnCommand 或 OnClick 未触发

php - jQuery Masonry Layout - 如何对齐图像

javascript - 使用 javascript 查找文本框值?