if (teacherName.Length == 0)
{
TeacherNamePanel.CssClass = "form-group has-error has-feedback";
Label span = new Label();
span.CssClass = "glyphicon glyphicon-remove form-control-feedback";
TeacherNamePanel.Controls.Add(span);
lblWarning.Text += "Please enter the name of teacher-in-charge! <br />";
}
else
TeacherNamePanel.CssClass = "form-group";
以及输入所有输入后的其余验证
string msg = "";
msg = accBLL.processCreateAccount(groupName, password, confirmPassword, school, teacherName, groupName, member1, member2, member3);
if (msg == "Sucess")
{
SuccessPanel.Visible = true;
lblSuccess.Text = "You have successfully signed up";
WarningPanel.Visible = false;
}
else
{
SuccessPanel.Visible = false;
lblWarning.Text += "There has been an error. Please try again!<br />";
WarningPanel.Visible = true;
}
以下是我用于显示验证消息的面板
<asp:Panel ID="WarningPanel" CssClass="alert alert-dismissable alert-danger" runat="server">
<asp:Label ID="lblWarning" runat="server"></asp:Label>
</asp:Panel>
以下是我保留输入控件的面板
<asp:Panel ID="TeacherNamePanel" CssClass="form-group has-feedback" runat="server">
<asp:TextBox ID="tbTeacherName" CssClass="form-control input-lg" placeholder="Teacher-in-charge" runat="server"></asp:TextBox>
</asp:Panel>
答案 0 :(得分:1)
设置lblWarning = False的EnableViewState属性。即使对于lblSuccess Label
,我也会建议设置EnableViewState =“False”