我有两个问题是 C# Web 应用程序中单选按钮列表的形式。这些问题需要与它们关联的字段验证器,并且我的 Web 控件末尾还有一个 ValidationSummary。当我单击“提交”按钮时,旁边的每个问题都会出现两个必填字段验证,并且验证摘要通过说明“回答以下问题:”正确工作,然后列出每个未选择的问题. 我遇到的问题是当我选择两个问题之一时,“必填字段”消息会在问题旁边消失,但不会出现在 ValidationSummary 中。How can I get the ValidationSummary to update or refresh when one of the questions in the error messages are selected? 如果我需要更具体,请告诉我。
<asp:RadioButtonList ID="Question1" RepeatLayout="Flow" runat="server">
<asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
<asp:ListItem Text="No" Value="No"></asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
Text="Required" ErrorMessage="Question 1"
Display="Dynamic" ControlToValidate="Question1"
EnableClientScript="true">
</asp:RequiredFieldValidator>
<asp:RadioButtonList ID="Question2" RepeatLayout="Flow" runat="server">
<asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
<asp:ListItem Text="No" Value="No"></asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
Text="Required" ErrorMessage="Question 2"
Display="Dynamic" ControlToValidate="Question2"
EnableClientScript="true">
</asp:RequiredFieldValidator>
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
HeaderText="Answer the following questions:"
DisplayMode="BulletList"
EnableClientScript="true"/>
<asp:Button ID="buttonSubmit" runat="server" Text="Submit"
OnClick="btnSubmit_OnClick"/>
//Code behind for button
protected void btnSubmit_OnClick(object sender, EventArgs e)
{
Response.BufferOutput = true;
Response.Redirect("~/Page.aspx");
}