Reputation: 166
I have an .aspx page which displays info from a database and lets users add new items.
The page contains an updatepanel. In that updatepanel, there is a gridview and a panel with some input elements:
<asp:Panel runat="server" ID="NewPersonPanel" DefaultButton="NewPersonButton" Visible="false">
<div id="newItemForm">
<label for="NewPersonName">Name:</label>
<asp:TextBox ID="NewPersonName" runat="server" MaxLength="50" />
<asp:RequiredFieldValidator ID="RequiredName" EnableClientScript="true" ControlToValidate="NewPersonName" ErrorMessage="Name must not be empty" ValidationGroup="NewPersonValidationGroup" runat="server" /><br />
<label for="NewPersonFirstName">First Name:</label>
<asp:TextBox ID="NewPersonFirstName" runat="server" MaxLength="50" />
<asp:RequiredFieldValidator ID="RequiredFirstName" EnableClientScript="true" ControlToValidate="NewPersonFirstName" ErrorMessage="First name must not be empty" ValidationGroup="NewPersonValidationGroup" runat="server" /><br />
<div id="newPersonControls">
<asp:LinkButton ID="NewPersonButton" ValidationGroup="NewPersonValidationGroup" runat="server" OnCommand="PersonGrid_Insert">Create</asp:LinkButton>
<asp:LinkButton ID="HideInputFormButton" runat="server" OnCommand="HideInputForm">Cancel</asp:LinkButton>
</div>
</div>
</asp:Panel>
Without the validation elements, the page works just fine. When I add the validation, things get weird; when I try to click the 'Create' button while the fields are empty, the red validation messages appear but this kills ALL postback on the page. If I fill in the fields, the red text disappears but I can't use any buttons anymore. Creating the new person, removing the form, sorting the grid, filtering the grid, grid paging.... all stops working. Using a debugger it doesn't seem like there is ever any call to my code behind anymore so it looks like the failed validation does something in javascript that causes all the other "__doPostBack" methods to fail.
I did find this thread: asp.net: Postback disabled after validation failed but there was never any answer there.
Upvotes: 0
Views: 1267
Reputation: 2554
Because you set validations you will not be able to postbacks.
however you can disable them by using ValidatorEnable(object,true/false)
this takes two parameters, first one is the object , second is whether to enable or disable.
in your case it is false.
but you have to do it for all controls in your form(for which you have set the validations) .
Upvotes: 2