Writing a custom validator for a dropdownlist that is using autopostback. Seems to ignore the validation altogether. Why is it ignored and is there an easy fix?
Note I did not use ControlToValidate
asp.net:
<asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional" Visible="true" RenderMode="Inline">
<ContentTemplate>
<asp:DropDownList ID="ddlCommandAssign" runat="server" AutoPostBack="true">
</asp:DropDownList>
<asp:CustomValidator id="val_command_assigned" runat="server"
ErrorMessage="* "
display="Static"
OnServerValidate="commandAssigned"
/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlCommandAssign"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
Behind Code:
Sub commandAssigned(ByVal source As Object, _
ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)
Dim s As String
s = ddlCommandAssign.SelectedValue
'if s = "1" then
' args.IsValid = true
'else
' args.IsValid = False
'end if
args.IsValid = False
End Sub
For debugging purposes, I want it to fail every time.
It doesn't seem to be executing the behind code at all.
For debugging, I added the line response.redirect("dummy.html") ... which never gets called, which also indicates (I think) that the validator never gets called.