【发布时间】:2021-10-21 12:31:55
【问题描述】:
我目前正在 vb.net 中处理一个项目,我无法让我的自定义验证器在 radcombobox 上工作。当我运行我的应用程序并测试验证时,它没有被调用,导致我的应用程序中断。我不是在研究客户端验证,只是在服务器端。下面是我一直在使用的代码。
aspx代码
<td>
<telerik:RadComboBox ID="radcomboboxListTimeZone" runat="server" BorderColor="#bbe0ef"
BorderWidth="2px" Width="400px" MaxHeight="200px"
DataSourceID="ObjectDataSourceListTimeZones"
DataTextField="DisplayName" DataValueField="StandardName" SelectedValue='<%#
Bind("TimeZoneStandardName")%>'>
</telerik:RadComboBox>
<asp:CustomValidator ID="CustomValidatorTimeZone" runat="server" ErrorMessage="Please select a
valid Time Zone Standard Name" ControlToValidate="radcomboboxListTimeZone"
OnServerValidate="CustomValidatorListTimeZone_ServerValidate">•</asp:CustomValidator>
</td>
服务器端代码
Protected Sub CustomValidatorListTimeZone_ServerValidate(ByVal source As Object, ByVal args As
ServerValidateEventArgs)
Dim radcomboboxListTimeZone As RadComboBox =
CType(FormViewTimeZones.FindControl("radcomboboxListTimeZone"), RadComboBox)
Dim selectedValue As String = radcomboboxListTimeZone.SelectedValue
If selectedValue = "Coordinated Universal Time" Then
args.IsValid = False
Else
args.IsValid = True
End If
End Sub
任何帮助将不胜感激。
【问题讨论】:
标签: vb.net validation radcombobox