Q:
I have a RequiredFieldValidator
on my page ,when i click the button which is (postback triggered
) it makes the postback
, although the field which is required wasn t entered !
What s the reason to this behavior?
My .aspx:
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btn_Search" />
</Triggers>
<ContentTemplate>
<asp:ImageButton ID="btn_Search" runat="server" ImageUrl="~/Images/save.png"
OnClick="btn_Search_Click" OnClientClick="return postbackButtonClick();" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:DropDownList ID="ddl_department" runat="server" Width="200px" OnSelectedIndexChanged="ddl_department_SelectedIndexChanged"
AutoPostBack="True">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ddl_department"
Display="Dynamic" ErrorMessage="*" InitialValue="-1"></asp:RequiredFieldValidator>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddl_study" runat="server" Width="200px">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ddl_study"
Display="Dynamic" ErrorMessage="*" InitialValue="-1"></asp:RequiredFieldValidator>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddl_department" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<script type="text/javascript">
var updateProgress = null;
function postbackButtonClick() {
updateProgress = $find("<%= UpdateProgress1.ClientID %>");
window.setTimeout("updateProgress.set_visible(true)", updateProgress.get_displayAfter());
return true;
}
</script>