locked
How can we pass information between two pages in metro app?

    Question

  • Hi All,

    How can we pass information between two pages in metro app? I am using HTML/Javascript.

    For example, I click on a item in list and i want to pass the information associated with that item to next page.

    - Ravi
    Thursday, May 31, 2012 3:33 PM

Answers

  • Simply define a global variable!

    You can hide the variable in an annonymous function and expose it through the WinJS.Namespace functionality as well.

    (function () { 'use strict'; //Make the object observable var data = "someData"; //Make name visible WinJS.Namespace.define('myNameSpace', { data: data }); })();

    And use it you your code:  var someOtherVar = myNameSpace.data;

    -Jeff


    Jeff Sanders (MSFT)


    Thursday, May 31, 2012 5:43 PM
    Moderator

All replies

  • Simply define a global variable!

    You can hide the variable in an annonymous function and expose it through the WinJS.Namespace functionality as well.

    (function () { 'use strict'; //Make the object observable var data = "someData"; //Make name visible WinJS.Namespace.define('myNameSpace', { data: data }); })();

    And use it you your code:  var someOtherVar = myNameSpace.data;

    -Jeff


    Jeff Sanders (MSFT)


    Thursday, May 31, 2012 5:43 PM
    Moderator
  • Thanks Jeff. I thought of that solution but the thing is I have my data inside a handler function and we can't define a Namespace inside a function. (apart from the anonymous function) Is there any other way around?

    -Ravi


    • Edited by ravipiplani Thursday, May 31, 2012 6:16 PM sentence correction
    Thursday, May 31, 2012 5:57 PM
  • You do not have to define the namespace inside the handler.

    Just do it on the first page and it will be accessible everywhere you need it.


    Jeff Sanders (MSFT)

    Thursday, May 31, 2012 6:23 PM
    Moderator
  • oh ok. Thanks:)

    -Ravi

    Thursday, May 31, 2012 6:36 PM
  • Hi JEFF

    ----------------------------------------------------------

    how can i do it in VB ? see i have a login form in mainpage.xaml and a modification of password option in blankpage1.xaml so i want to update my password so how can i take it ?


    jDmAc Corp

    Thursday, August 22, 2013 3:52 PM