2015-02-23 44 views
0

我正在开发一个应用程序,我需要从Facebook设置一些用户数据。因此,使用WebAuthentication经纪人,我让用户登录,然后获取信息并将其设置为文本框值。信息被正确提取,但值不在Textbox中设置。我无法弄清楚原因。有人可以帮忙吗?TextBox动态文本

+1

你可以贴一些代码吗?你如何打开文本框? – 2015-02-23 10:20:23

+2

你使用哪种技术?它是WPF,Windows窗体,ASP.NET? – 2015-02-23 10:42:54

回答

0

动态设置文本框的文本WP8.1

这是我设置数据的函数。

async public void SignUpUsingFacebook(string response) 
    {    
     if (Utility.isInternetAvailable()) 
     { 
      try { MainPage.StartAnimation(); 
      MainPage.loaderGrid.Visibility = Visibility.Visible; 
      } 
      catch 
      { 
       setAnimation(); 
       StartAnimation(); 
       loaderGrid.Visibility = Visibility.Visible; 
      } 
      string token = response.Substring(response.IndexOf('=') + 1); 
      string fbGetInfo = "https://graph.facebook.com/me?access_token=" + token; 
      HttpResponseMessage msg = await new HttpClient().GetAsync(new Uri(fbGetInfo), HttpCompletionOption.ResponseContentRead); 
      if (msg.IsSuccessStatusCode) 
      { 
       try 
       { 
        string fbData = await msg.Content.ReadAsStringAsync(); 
        JObject j = JObject.Parse(fbData); 
        string fbId = j["id"].ToString(); 
        txt_user_Name.Text = fbId; 
        txt_user_Name.Visibility = Visibility.Collapsed; 
        txt_first_Name.Text = j["first_name"].ToString(); 
        txt_last_Name.Text = j["last_name"].ToString(); 
        txt_email_Address.Text = j["email"].ToString(); 
        txt_retype_email_Address.Text = j["email"].ToString(); 
        gender = j["gender"].ToString(); 
        if (gender.Equals("male", StringComparison.OrdinalIgnoreCase) || gender.Equals("boy", StringComparison.OrdinalIgnoreCase)) 
        { 
         boy.Visibility = Visibility.Collapsed; 
         boySelected.Visibility = Visibility.Visible; 
         girlSelected.Visibility = Visibility.Collapsed; 
         girl.Visibility = Visibility.Visible; 
        } 
        else if (gender.Equals("female", StringComparison.OrdinalIgnoreCase) || gender.Equals("girl", StringComparison.OrdinalIgnoreCase)) 
        { 
         girlSelected.Visibility = Visibility.Visible; 
         boySelected.Visibility = Visibility.Collapsed; 
         girl.Visibility = Visibility.Collapsed; 
         boy.Visibility = Visibility.Visible; 
        } 
       } 
       catch { }