无效令牌';'在类、结构或接口成员声明中
本文关键字:接口 成员 声明 令牌 在类 无效 结构 | 更新日期: 2023-09-27 18:16:56
我试图在ASP中创建一个用户登录表单。. NET web表单使用web控件。当我编译代码时,我在设计器类中得到这个错误。登录表单的代码如下:
<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;
}
c#中不允许在变量名中使用破折号。例如,您可以将signin-email
指定为ID
来代替asp:TextBox
。自动生成的代码将在c#代码中使用这些值。
将字段重命名为使用下划线,而不是破折号