名称'txtActivationPIN'在当前上下文中不存在 [英] the name 'txtActivationPIN' does not exist in the current context

查看:78
本文介绍了名称'txtActivationPIN'在当前上下文中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

祝福所有福音传道者好日子

Good day to you all evangelists

我在下面的代码中收到此错误(当前上下文中不存在名称'txtActivationPIN'),请帮助

I am getting this error (the name 'txtActivationPIN' does not exist in the current context) in the code below kindly help

MainPage.xaml.cs

MainPage.xaml.cs

使用System;

使用System.Collections.Generic;

使用System.Linq;

使用System.Net;

使用System.Windows;

使用System.Windows.Controls ;

使用System.Windows.Navigation;

使用Microsoft.Phone.Controls;

使用Microsoft.Phone.Shell;

使用HttpRequest.Resources;

使用System.IO;



名称空间HttpRequest

{

    public partial class MainPage:PhoneApplicationPage

    {

        //构造函数

        public MainPage()

        {

            InitializeComponent();
$


            //本地化ApplicationBar的示例代码

            // BuildLocalizedApplicationBar();

        }


        private void Button_Click_1(对象发件人,RoutedEventArgs e)

        {

            string ThePIN = txtActivationPIN.Text;

            string TheAppType =" Windows Phone";

            string TheAppName =" OpenHeavens 2014"; $
            string WebServiceResponse = ActivatePIN(txtPIN.text,TheAppType,TheAppName);
$
        }


        static string ActivatePIN(string ActivationPIN,string AppType,string AppName)

        {
$


            //剩余代码

           尝试{

                        串TheReply = QUOT;英寸;

                        串TheFullURL = QUOT;英寸;

                         string TheURL =

            " http://iopenheavens.mobilixe.com/ws/iopenheavens.asmx/wsActivatePIN" ;;

            ;             TheFullURL = TheURL +"?ActivationPIN =" +

                    &NBSP ;   ActivationPIN +"& AppType =" +

                    &NBSP ;   AppType +"& AppName =" + AppName的;

                   &NBSP ;    // 准备网络请求...

                         System.Net.HttpWebRequest myRequest;

                 &NBSP ;      System.Net.HttpWebRequest.Create(TheFullURL);

               &NBSP ;        System.Net.HttpWebRequest;

                         myRequest.ContentType =

                         "应用/ X WWW的窗体-urlencoded英寸;

              &NBSP ;         myRequest.Method = QUOT; GET英寸;

                &NBSP ;       System.Net.HttpWebResponse ReturnResponse =

            ((System.Net.HttpWebResponse)(myRequest.GetResponse()));

            StreamReader readStream = new

            StreamReader(ReturnResponse.GetResponseStream());

                   ;       TheReply = readStream.ReadToEnd();

                 

       ReturnResponse.Close();

                         readStream.Close();

                        返回TheReply;

                    }
                    catch(例外情况){

                        扔EXC;

                   &NBSP ;   返回"英寸;

                     }¥b $ b   

             }
        }


     }

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using HttpRequest.Resources;
using System.IO;

namespace HttpRequest
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string ThePIN = txtActivationPIN.Text;
            string TheAppType = "Windows Phone";
            string TheAppName = "OpenHeavens 2014";
            string WebServiceResponse = ActivatePIN(txtPIN.text, TheAppType, TheAppName);
        }

        static string ActivatePIN(string ActivationPIN, string AppType, string AppName)
        {

            //The remaining code
            try {
                        string TheReply = "";
                        string TheFullURL = "";
                        string TheURL =
            "http://iopenheavens.mobilixe.com/ws/iopenheavens.asmx/wsActivatePIN";
                        TheFullURL = TheURL + "?ActivationPIN=" +
                        ActivationPIN + "&AppType=" +
                        AppType + "&AppName=" + AppName;
                        //  Prepare web request...
                        System.Net.HttpWebRequest myRequest;
                        System.Net.HttpWebRequest.Create(TheFullURL);
                        System.Net.HttpWebRequest;
                        myRequest.ContentType =
                        "application/x-www-form-urlencoded";
                        myRequest.Method = "GET";
                        System.Net.HttpWebResponse ReturnResponse =
            ((System.Net.HttpWebResponse)(myRequest.GetResponse()));
            StreamReader readStream = new
            StreamReader(ReturnResponse.GetResponseStream());
                        TheReply = readStream.ReadToEnd();
                 
       ReturnResponse.Close();
                        readStream.Close();
                        return TheReply;
                    }
                    catch (Exception exc) {
                        throw exc;
                        return "";
                    }
   
             }
        }

     }

MainPage.xaml

MainPage.xaml

< phone:PhoneApplicationPage

    x:Class =" HttpRequest.MainPage"

    xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x =" http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:phone =" clr-namespace:Microsoft.Phone.Controls; assembly = Microsoft.Phone"
$
    xmlns:shell =" clr-namespace:Microsoft.Phone.Shell; assembly = Microsoft.Phone"
$
    xmlns:d =" http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc =" http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable =" d"

    FontFamily =" {StaticResource PhoneFontFamilyNormal}"&
    FontSize =" {StaticResource PhoneFontSizeNormal}" $
    Foreground =" {StaticResource PhoneForegroundBrush}" $
    SupportedOrientations = QUOT;肖像" Orientation =" Portrait" b
    shell:SystemTray.IsVisible =" True">



    <! - LayoutRoot是放置所有页面内容的根网格 - >
$
    < Grid x:Name =" LayoutRoot"背景="透明">

        < Grid.RowDefinitions>

            < RowDefinition Height =" Auto" />

            < RowDefinition Height =" *" />

        < /Grid.RowDefinitions>



        <! - LOCALIZATION注意:

           要本地化显示的字符串,请将其值复制到适当的名称为<
           应用程序中性语言资源文件(AppResources.resx)中的键然后是
           替换属性的引号之间的硬编码文本值

           带有绑定子句,其路径指向该字符串名称。



           例如:
$


               文本= QUOT; {结合路径= LocalizedResources.ApplicationTitle源= {StaticResource的LocalizedStrings}}"



&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;此绑定指向名为"ApplicationTitle"的模板字符串资源。



           &NBSP;在"项目属性"选项卡中添加支持的语言将创建一个
          每种语言的新resx文件,可以带有您的转换价值
           UI字符串。这些示例中的绑定将导致值为
          要从.resx文件中提取的属性,该文件与
         - >
$


        <! - TitlePanel包含应用程序的名称和页面标题 - >
$
        < StackPanel x:Name =" TitlePanel" Grid.Row = QUOT; 0"保证金="12,17,0,28">

            < TextBlock Text =" HTTP REQUEST" Style =" {StaticResource PhoneTextNormalStyle}"保证金=" 12,0" />

            < TextBlock Text =" page name 1"余量= QUOT; 9,-7,0,0" Style =" {StaticResource PhoneTextTitle1Style}" />

        < / StackPanel>



        <! - ContentPanel - 在此处添加其他内容 - >

        < Grid x:Name =" ContentPanel" Grid.Row = QUOT 1 QUOT;保证金=" 12,0,12,0>>

            < TextBlock Horizo​​ntalAlignment =" Left"余量= QUOT; 10,10,0,0" TextWrapping = QUOT;包覆与QUOT;文字="在下方输入你的激活密码" VerticalAlignment = QUOT;陀螺"
高度="66"宽度=" 436" />

            < TextBox Horizo​​ntalAlignment =" Left"高度= QUOT; 72"余量= QUOT; 10,81,-10,0" TextWrapping = QUOT;包覆与QUOT;文本= QUOT;" VerticalAlignment = QUOT;陀螺"宽度=" 456" />

            < Button Content =" Activate"的Horizo​​ntalAlignment = QUOT;左"余量= QUOT; 129,158,0,0" VerticalAlignment = QUOT;陀螺"宽度= QUOT; 209"点击=" Button_Click_1" />
$


        < / Grid>



        <! - 取消注释以查看对齐网格,以帮助确保您的控件为$
           在共同边界上对齐。 该图片的最高保证金为-32px至
           帐户系统托盘。将此设置为0(或一起删除保证金)

           系统托盘是否隐藏。



           发货前请删除此XAML和图像本身.-->
$
        <! - < Image Source =" /Assets/AlignmentGrid.png" VerticalAlignment = QUOT;陀螺"高度= QUOT; 800"宽度= QUOT; 480"余量= QUOT; 0,&-32,0,0 QUOT; Grid.Row = QUOT; 0" Grid.RowSpan = QUOT; 2英寸
IsHitTestVisible =" False" /> - >

    < / Grid>



< / phone:PhoneApplicationPage>

<phone:PhoneApplicationPage
    x:Class="HttpRequest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- LOCALIZATION NOTE:
            To localize the displayed strings copy their values to appropriately named
            keys in the app's neutral language resource file (AppResources.resx) then
            replace the hard-coded text value between the attributes' quotation marks
            with the binding clause whose path points to that string name.

            For example:

                Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"

            This binding points to the template's string resource named "ApplicationTitle".

            Adding supported languages in the Project Properties tab will create a
            new resx file per language that can carry the translated values of your
            UI strings. The binding in these examples will cause the value of the
            attributes to be drawn from the .resx file that matches the
            CurrentUICulture of the app at run time.
         -->

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="HTTP REQUEST" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
            <TextBlock Text="page name 1" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <TextBlock HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="Input your activation PIN below" VerticalAlignment="Top" Height="66" Width="436"/>
            <TextBox HorizontalAlignment="Left" Height="72" Margin="10,81,-10,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="456"/>
            <Button Content="Activate" HorizontalAlignment="Left" Margin="129,158,0,0" VerticalAlignment="Top" Width="209" Click="Button_Click_1"/>

        </Grid>

        <!--Uncomment to see an alignment grid to help ensure your controls are
            aligned on common boundaries.  The image has a top margin of -32px to
            account for the System Tray. Set this to 0 (or remove the margin altogether)
            if the System Tray is hidden.

            Before shipping remove this XAML and the image itself.-->
        <!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
    </Grid>

</phone:PhoneApplicationPage>

非常感谢您提前回复

Jayjay john

Jayjay john

推荐答案

您没有为XAML中的TextBox指定名称。因此,在后面的代码中你无法访问它。

You are not assigning a name to your TextBox in the XAML. Therefore in code behind you can't access it.

TextBox声明如下:

The TextBox is declared like this:

< TextBox Horizo​​ntalAlignment =" Left"高度= QUOT; 72"余量= QUOT; 10,81,-10,0" TextWrapping = QUOT;包覆与QUOT;文本= QUOT;" VerticalAlignment = QUOT;陀螺" Width =" 456" />

<TextBox HorizontalAlignment="Left" Height="72" Margin="10,81,-10,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="456"/>

如果您将其更改为:

< TextBox x:Name =" txtActivationPIN" Horizo​​ntalAlignment =" Left"高度= QUOT; 72"余量= QUOT; 10,81,-10,0" TextWrapping = QUOT;包覆与QUOT;文本= QUOT;" VerticalAlignment = QUOT;陀螺" Width =" 456" />

<TextBox x:Name="txtActivationPIN" HorizontalAlignment="Left" Height="72" Margin="10,81,-10,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="456"/>

它应该有效。我没有看过你的其余代码,但这应该可以解决你在编译过程中遇到的问题。

It should work. I have not looked at the rest of your code but this should fix the problem you get during compilation.


这篇关于名称'txtActivationPIN'在当前上下文中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆