Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

We have a SP2010 site where validation is done using the jquery validate plugin. In a custom WebPart the layout has few common fields, a dropdown and multiple panels which load based on the value selected in the dropdown. The issue is that in case someone clicks on save first and there are validation errors(required field) validation the OnSelectedIndexChanged stops firing.

<asp:DropDownList ID="ddl1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl1_SelectedIndexChanged"></asp:DropDownList>


Multiple panels, each with a save and close button:
XML
<asp:Button ID="btnSubmit1" runat="server" Text="Save" onclick="btnSubmit1_Click" />
<asp:Button ID="btnClose1" runat="server" CssClass="cancel" CausesValidation="false" Text="Close" onclick="btnClose1_Click" />


Script- jQuery Validation:
$("form").validate({
        rules:{
	   REQUIRED VALIDATION RULES FOR MULTIPLE FIELDS
	}
    });


After the page load the dropdown posts back just fine as long as no errors have occurred but once there are validation errors then even after the errors are corrected the page does not post back on the change of dropdown.

Really appreciate any help on this.
Posted

1 solution

Hi,

Just found a client-side solution. If I add a

$('.dropdownclassname').change(function(){ logic for panel change using .show() and .hide() })


function in the code there is no need for a server side postback. The code is working fine with this solution and the change event is firing properly.
 
Share this answer
 
Comments
Member 11653043 10-Jul-15 18:40pm    
Can you explain more about the part {logic for panel ...}
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900