首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >类、结构或接口成员声明中的标记';‘无效

类、结构或接口成员声明中的标记';‘无效
EN

Stack Overflow用户
提问于 2015-10-08 21:24:35
回答 1查看 1.4K关注 0票数 1

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

代码语言:javascript
复制
<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>

为什么我会得到这个错误?

编辑:

以下是设计器代码

代码语言:javascript
复制
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;
    }
EN

回答 1

Stack Overflow用户

发布于 2015-10-08 21:39:10

在C#中不允许在变量名中使用短划线。例如,您可以通过将signin-email指定为asp:TextBoxID来实现。自动生成的代码将在C#代码中使用这些值。

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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33017175

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档