我正在使用 C# 在 ASP.NET 中开发一个应用程序。在我的应用程序中,有两个页面,例如 abc.aspx
和 xyz.aspx
。我正在 abc.aspx
的 iframe
中打开 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/