无效令牌';'在类,结构或接口成员声明中

时间:2015-10-08 13:24:35

标签: c# asp.net webforms

我尝试使用Web控件在ASP.NET webforms中创建用户登录表单。编译代码时,我在设计器类中遇到此错误。登录表单的代码如下:

<form class="cd-form">
    <p class="fieldset">
        <label class="image-replace cd-email" for="signin-email">Username</label>
        <asp:TextBox class="full-width has-padding has-border" ID="signin-email" type="email" placeholder="E-mail" runat="server"></asp:TextBox>
        <span class="cd-error-message">Error message here!</span>
    </p>

    <p class="fieldset">
        <label class="image-replace cd-password" for="signin-password">Password</label>
        <asp:TextBox class="full-width has-padding has-border" ID="signin-password" type="text" placeholder="Password" runat="server"></asp:TextBox>
        <a href="#0" class="hide-password">Hide</a>
        <span class="cd-error-message">Error message here!</span>
    </p>

    <p class="fieldset">
        <input type="checkbox" id="remember-me" checked>
        <label for="remember-me">Remember me</label>
    </p>

    <p class="fieldset">
      <asp:Button ID="btn_login" runat="server" value="Login" OnClick="btn_login_Click1" />
    </p>
</form>

为什么我收到此错误?

编辑:

这是设计师代码

public partial class main {

        /// <summary>
        /// signin-email control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.TextBox signin-email;

        /// <summary>
        /// signin-password control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.TextBox signin-password;

        /// <summary>
        /// btn_login control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button btn_login;
    }

1 个答案:

答案 0 :(得分:4)

在C#中不允许在变量名中使用破折号。例如,您可以为signin-email指定IDasp:TextBox。自动生成的代码将在C#代码中使用这些值。

重命名字段以使用下划线,而不是短划线。