NPDA 0 Light Poster

i wanna read from a web service to a text block ... i defined a web service in the main page then i declared object of the main page into info page to call values which it come from web service but this code keep the text block empty that mean it doesn't read the values from the web service any one can help ???:)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Xml.Linq;
using System.Xml;
using System.Text;

namespace PhoneApp4
{
    public partial class info : PhoneApplicationPage
    {
        MainPage mp = new MainPage();



        public info()
        {



            InitializeComponent();

            WebClient inf = new WebClient();
            // client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);

           inf.DownloadStringCompleted+=new DownloadStringCompletedEventHandler(inf_DownloadStringCompleted);


            //name.Text = 
        }
        public void inf_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
           string pass = mp.passwordBox1.Password;

           string id = mp.tx.Text;

            nn.Text =id;

           }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

        }

    }
}




main class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO;
using System.IO.IsolatedStorage;
using System.Xml.Linq;

namespace PhoneApp4
{

    public partial class MainPage : PhoneApplicationPage
    {
        Class1 info = new Class1();


        public string result;
        public string status;
        public string userId;
        public string msg;
        public string url;  
        WebClient client;
        // Constructor
        public MainPage()
        {


            InitializeComponent();

            client = new WebClient();
            client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);

        }

        public void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {


            if (e.Error == null)
            {


                XElement resultElements = XElement.Parse(e.Result);

                status = resultElements.Element("status").Value;
                if (resultElements.Element("userId") != null)
                {
                    userId = resultElements.Element("userId").Value;
                    MessageBox.Show(userId);
                }



                msg = resultElements.Element("msg").Value;
                if (status == "true")
                    NavigationService.Navigate(new Uri("/info.xaml", UriKind.Relative));
                // MessageBox.Show("Logged in");
                else
                    textBlock1.Text = "invalid user name or passwaord";

                // MessageBox.Show("not logged in");

                //result = e.Result;
            }

        }

        private void checkBox1_Checked(object sender, RoutedEventArgs e)
        {

        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {


                url = "http://82.212.89.6:888/mob/resources/stdInfo/authenticate/" + tx.Text + "/" + passwordBox1.Password + "/1/570322308ce1121cba1b93f5acc9ebd4733ef2bca90ef942a2cfa224f0aa08dc/1";
                client.DownloadStringAsync(new Uri(url));



        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {



            NavigationService.Navigate(new Uri ("/mail.xaml",UriKind.Relative));

        }

     public void tx_TextChanged(object sender, TextChangedEventArgs e)
        {

        }

    public void passwordBox1_PasswordChanged(object sender, RoutedEventArgs e)
     {

     }
        //http://82.212.89.6:888/mob/ should changable so should be at file.
    }

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.