locked
Passing Multiple array values through a query string RRS feed

  • Question

  • User-1618168713 posted

    Hello,

    I have a query string which contains the value of more than one Array, I want to pass these values from Page 1 to Page 2 and then distribute the array values into new arrays on Page 2.

    Here is what I have so far. 

    Page 1

    string queryValuesRedirect = "WebResponsePage.aspx?";

                queryValuesRedirect += "QueryValues=" + EFFinal + " " + IFFinal;
                Response.Redirect(queryValuesRedirect);

    Page 2

    string[] EFFinal = new string[1000];
                string[] IFFinal = new string[1000];
    
     string[] splittedstring = queryValues.Split(new Char[] { ' ' });                    
                EFFinal[0] = (splittedstring[0]);
    IFFinal[0] = (splittedstring[1];

    All that I get returned in EFFinal and IFFinal is System.String?

    Is there a way to do this?

    Thanks

    Wednesday, February 16, 2011 6:39 AM

Answers

  • User619554136 posted

    Below are the steps to achive your requirement. this approch wont' use any query string machanism. and data will not be exposed to the client browser. so your data is safe at server side. also your data can be typesafe as you access it using a public property which is of type array.

    1. Expose a public property in First Page Ex: - MyList
    2. User Server side event on the component from where you navigate in first page.
    3. In the event. Store your array in the public property you created in step 1.
    4. Do Server.Transfer("Secondpage.aspx");
    5. In Second Page load event. Get your previous page array using

     

    //What is in below code?? --->
    //WebForm2 is a codebehind class to your second page.
    //MyList is the public property in the first page where you stored your array before navigating to second page.
    
    WebForm2 myPage2 = Page.PreviousPage as WebForm2;
    //Define someArray as an Array in Page2.
    this.someArray = myPage2.MyList; //Access the array of previous page using the previous page property created in step1.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 16, 2011 8:25 AM

All replies

  • User-1161841047 posted

    you can't do that with Query String ,because the max lengh of th URL around 255.

    Wednesday, February 16, 2011 7:01 AM
  • User-1618168713 posted

    I see! Do you have any suggestions on a alternative?

    Thanks

    Wednesday, February 16, 2011 7:12 AM
  • User-1161841047 posted

    You can use Server.Transfer:


    Context.Items("myParam") = YourString
    Server.Transfer("default2.aspx")

    Then, in default2.aspx:

    YourNewString= CType(Context.Items("myParam"),String)

     

    For more informatin and other ways you can find this link : http://msdn.microsoft.com/en-us/magazine/cc300437.aspx

     

    Wednesday, February 16, 2011 7:20 AM
  • User619554136 posted

    Below are the steps to achive your requirement. this approch wont' use any query string machanism. and data will not be exposed to the client browser. so your data is safe at server side. also your data can be typesafe as you access it using a public property which is of type array.

    1. Expose a public property in First Page Ex: - MyList
    2. User Server side event on the component from where you navigate in first page.
    3. In the event. Store your array in the public property you created in step 1.
    4. Do Server.Transfer("Secondpage.aspx");
    5. In Second Page load event. Get your previous page array using

     

    //What is in below code?? --->
    //WebForm2 is a codebehind class to your second page.
    //MyList is the public property in the first page where you stored your array before navigating to second page.
    
    WebForm2 myPage2 = Page.PreviousPage as WebForm2;
    //Define someArray as an Array in Page2.
    this.someArray = myPage2.MyList; //Access the array of previous page using the previous page property created in step1.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 16, 2011 8:25 AM
  • User-1618168713 posted

    Hello,

     

    Thanks ever so much for this, that is actually a much better way for me to do this!

    Really appreciate the help!

    Wednesday, February 16, 2011 10:34 AM