Access previous page controls value

956 views Asked by At

i have a problem i want to access controls of previous pages values. I know that i can use postbackurl but i must use OnClientClick property because i must call javascript method and according to the criterias my url change. Below method is called OnClientClick property. This page name 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";
        }


    }

I want to access Calculator.aspx controls values in Change.aspx. How can i do that.

1

There are 1 answers

0
Syed Ali Taqi On

In source page, which in your case is Calculator.aspx, add this:

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

On the target page, which in your case is Change.aspx, add a @ PreviousPageType page directive that points to the source page.

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

Now in target page use PreviousPage property to access values.

String val = PreviousPage.Value1;