【发布时间】:2015-10-08 21:39:09
【问题描述】:
我正在尝试使用 Web 控件在 ASP.NET 网络表单中创建用户登录表单。编译代码时,我在设计器类中收到此错误。登录表单的代码如下:
<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;
}
【问题讨论】:
-
能否添加带有错误和错误信息的截图?
-
你能把designer.cs文件的相关部分也贴出来吗?
-
从您的
ID属性中删除-- 它们应该是常规的 .net 标识符(不允许使用破折号)。 -
@AhmedMujtaba 您最初的问题是缺少设计器的相关代码,这使得诊断变得困难。有些用户没有耐心等待您编辑和更正问题,或者根本不相信您会这样做。这是否是合理的行为是另一回事。
-
这个错误是否微不足道也没关系。并非每个开发人员都从内存中了解完整的语言规范。我当然不知道。这是一个完全有效的问题