×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    11

    pass the URI parameter/value to linq

    hi. im having trouble passing the value that i get from another page to my linq.
    my code is:

    on my first page i have..
    Code:
    NavigationService.Navigate(new Uri("/ViewPage.xaml?articleID=I", UriKind.Relative));
    then on my 2nd page to retrieve the value i have..
    Code:
    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
            {
                string articleNo = NavigationContext.QueryString["articleID"];
                base.OnNavigatedTo(e);
                MessageBox.Show("ID: " + articleNo);
            }
    problem is on my 2nd page.. its not showing the data if i put it like this..
    the articleNo is not returning the value from the recent page hence the linq is having a null result.
    Code:
    XDocument loadedData = XDocument.Load("phconstitution.xml");
    
                var data = from query in loadedData.Descendants("article")
                           where query.Attribute("Title").Value == articleNo
                           select new article()
                           {
                               Title  = query.Attribute("Title").Value,
                               SubTitle = query.Attribute("SubTitle").Value,
                               Content = query.Attribute("Content").Value
                           };

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2012
    Location
    Bilbao
    Posts
    53

    Re: pass the URI parameter/value to linq

    Hi!

    In your messageBox you see the correct value in articleNo? Are you tested to substitute articleNo in your LinQ with the direct value to test if it is a problem with the query? Are you executing the linq on the OnNavigatedTo method??

  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    11

    Re: pass the URI parameter/value to linq

    hi thanks for the response josueyeray. it did worked when i put my linq inside the OnNavigatedTo method.
    just one more question though. before i was executing my linq after InitializeComponent(); is this right? i mean is this the equivalent of a form_load in wp7?
    thanks for the help.

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2012
    Location
    Bilbao
    Posts
    53

    Re: pass the URI parameter/value to linq

    Hi!

    In Windows Phone the pages has the Loaded event that you can attach to and is raised when the page is complete loaded.

    But, for Fast app switching and tombstoning is better to do all your page initialization in the OnNavigatedTo method, because is called every time the page is showed even if you are coming from tombstoning or FAS.

  5. #5
    Registered User
    Join Date
    Jan 2009
    Posts
    19

    Re: pass the URI parameter/value to linq

    please see the link its navigate one page to second page
    http://blogs.microsoft.co.il/blogs/s...es-part-1.aspx

    see the link
    http://stackoverflow.com/questions/4...rlight-and-wp7

    other way find the xml path use IsolatedStorageFileStream

    XDocument xmlDoc = null;
    IsolatedStorageFileStream isoStream;
    IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication()
    using (isoStream = new IsolatedStorageFileStream("phconstitution.xml", FileMode.OpenOrCreate, isoStore))
    xmlDoc = XDocument.Load(isoStream);
    Title = xmlDoc.Element("parentNode").Element("Title").Value.ToString();
    Last edited by pravejnini; 2012-02-28 at 10:05.

Similar Threads

  1. How to pass input parameter to cgi using J2me?
    By maniohile in forum Mobile Java General
    Replies: 7
    Last Post: 2011-04-24, 12:10
  2. Pass QPixmap as a parameter to method
    By forceoflight in forum Qt
    Replies: 3
    Last Post: 2011-01-07, 22:56
  3. Replies: 4
    Last Post: 2011-01-06, 13:16
  4. How to pass parameter to your midlet from .jad file
    By Nabil_java in forum Mobile Java General
    Replies: 3
    Last Post: 2008-06-01, 08:36
  5. how to pass a parameter in symbians60
    By khaliloenit in forum Symbian User Interface
    Replies: 1
    Last Post: 2008-03-26, 11:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×