Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 访问上一页控件值_C#_Javascript_Asp.net_Postback_Postbackurl - Fatal编程技术网

C# 访问上一页控件值

C# 访问上一页控件值,c#,javascript,asp.net,postback,postbackurl,C#,Javascript,Asp.net,Postback,Postbackurl,我有一个问题,我想访问上一页值的控件。我知道我可以使用postbackurl,但我必须使用OnClientClick属性,因为我必须调用javascript方法,并根据标准更改我的url。下面的方法称为OnClientClick属性。此页面名为Calculator.aspx function redirectSellPage() { var type = getParameterByName('type'); if (type == 'tes

我有一个问题,我想访问上一页值的控件。我知道我可以使用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";
        }


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

在源代码页中,您的示例是Calculator.aspx,添加以下内容:

public String Value1
{
get
{
    return YourTextBoxId.Text;
}
}
在目标页面(在您的示例中是Change.aspx)上,添加指向源页面的@PreviousPageType页面指令

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

为什么不将Calculator.aspx控件的值附加到URL?可以使用dopostbackwithoptions,而不是设置window.location.href=URL。或者您可以将form.action设置为url并执行form.submit。在这种情况下,您可以使用Request.Form[“name”]访问上一页控件。
String val = PreviousPage.Value1;