0

我有一个问题,我想访问以前页面值的控件。我知道我可以使用 postbackurl 但我必须使用 OnClientClick 属性,因为我必须调用 javascript 方法并根据我的 url 更改的标准。下面的方法称为 OnClientClick 属性。此页面名称 Calculator.aspx

        function redirectSellPage() {

        var type = getParameterByName('type');


        if (type == 'test') {
            window.location.href = "Change.aspx?PageType=a";
        } else if (a == null || a == "") {
            window.location.href = "Change.aspx?PageType=b";
        } else {
            window.location.href = "Change.aspx?PageType=c";
        }


    }

我想访问 Change.aspx 中的 Calculator.aspx 控件值。我怎样才能做到这一点。

4

1 回答 1

0

在源页面(在您的情况下是 Calculator.aspx)中,添加以下内容:

public String Value1
{
get
{
    return YourTextBoxId.Text;
}
}

在目标页面(在您的情况下是 Change.aspx)上,添加一个指向源页面的 @PreviousPageType 页面指令。

<%@ PreviousPageType VirtualPath="~/Calculator.aspx" %>

现在在目标页面中使用 PreviousPage 属性来访问值。

String val = PreviousPage.Value1;
于 2014-05-21T10:42:31.213 回答