我在网格中需要字段验证器
<EditItemTemplate>
<asp:TextBox ID="txtfirstname" runat="server" Text='<%# Bind("FirstName")%>' ValidationGroup="ValidateSender" MaxLength="50"></asp:TextBox>
<asp:RequiredFieldValidator ID="ReqedFieldValtorFirstName" runat="server" ControlToValidate="txtfirstname" ErrorMessage="Input is mandatory" ForeColor="Red" SetFocusOnError="True" ValidationGroup="ValidateSender"></asp:RequiredFieldValidator>
</EditItemTemplate>
我还有一个按钮来触发错误
<asp:Button ID="btnSave" runat="server" Visible="false" ToolTip="Save" Text="Save" CausesValidation="true" ValidationGroup="ValidateSender" UseSubmitBehavior="true" />
我的服务器端按钮是
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Try
Page.Validate()
If Page.IsValid Then
Dim SendersList As CommonFramework.BaseList(Of NotificationSendersBO) = New CommonFramework.BaseList(Of NotificationSendersBO)()
SendersList = FindControlRecursiveAndGetBOs()
m_senderPresenter.SaveSenderDetails(SendersList)
m_senderPresenter.GetSenderDetails()
btnReset.Visible = False
btnSave.Visible = False
End If
Catch ex As Exception
LogException.Publish(ex)
End Try
End Sub
但是服务器端点击始终是触发,而在客户端,所需的字段验证器不起作用。
更新:我已完成调试,并在执行服务器端点击事件后触发,这不是预期的。
让我知道如何解决这个问题。 任何帮助表示赞赏。