Tuesday 15 September 2015

c# - Required Field Validator in Ajax Accordion Pane is not working -



c# - Required Field Validator in Ajax Accordion Pane is not working -

we using ajax accordion pane. dynamically binding ajax accordion info set. not sure how much pane wil bind.

now added few textbox , 1 button in each accordion pane mandotory used required field validator.

the problem when click buton in first pane textbox in first pane showing "it required" fine if typed textbox in first pane. not able save since textbox in remaining pane showing "it required". please guide me.

<cc1:accordion id="accrcvdetails" runat="server" selectedindex="-1" contentcssclass="accordion-content" requireopenedpane="false" headercssclass="accordion-header" headerselectedcssclass="accordionselected" onitemcommand="accrcvdetails_itemcommand" onitemdatabound="accrcvdetails_itemdatabound"> <headertemplate> </headertemplate> <contenttemplate> <td class="searchlabel"> <asp:label id="lblnotes" runat="server" text="notes:"></asp:label> </td> <td class="searchtext" colspan="3"> <asp:textbox runat="server" id="txtnotes" width="100%" textmode="multiline" height="35px" /> <asp:requiredfieldvalidator controltovalidate="txtnotes" text="note field required" runat="server" /> </td> <td> <td style="text-align: right" colspan="8"> <asp:button id="btnsave" cssclass="searchbutton accbtnsave" runat="server" commandname="save" text="save" /> </td> </contenttemplate> </cc1:accordion>

you need mention validationgroup every textbox , button, binding accordion @ runtime, need bind validationgroup @ runtime property has unique/different value every accordian. lets binding accordion rows of groups, can mention groupid in validationgroup then. updated code must looks alike:

<asp:requiredfieldvalidator controltovalidate="txtnotes" text="note field required" runat="server" validationgroup='<%# eval("groupid") %>'/> <asp:button id="btnsave" cssclass="searchbutton accbtnsave" runat="server" commandname="save" text="save" validationgroup='<%# eval("groupid") %>'/>

this way each accordion has own validationgroup , clicking on button not fire validators in other accordions

c# asp.net ajax c#-4.0 asp.net-ajax

No comments:

Post a Comment