0

i have a required fields in the 2nd and 3rd ajax accordion panels. i have the setfocus=true on my required field validator the the appropriate panel does not automatically open.

is there a way i can get it to open the panel, where the next required field is located?

 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
    <asp:Accordion   
        ID="Accordion1" 
        runat="server">  

    <Panes >
    <asp:AccordionPane runat="server" >
    <Header>General Information </Header>
    <content>
    <asp:textbox id="textbox1" runat="server"/>
    </content>
    </asp:AccordionPane>
    <asp:AccordionPane runat="server" >
    <Header>Other Information </Header>
    <content>
    <asp:textbox id="textbox2" runat="server"/>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" SetFocusOnError="true"  runat="server"
             ErrorMessage="error on textbox 2"  ControlToValidate="textbox2" ForeColor= "Red" ValidationGroup="main">*</asp:RequiredFieldValidator>
    </content>
    </asp:AccordionPane>
<asp:AccordionPane runat="server" >
    <Header>More Information </Header>
    <content>
    <asp:textbox id="textbox3" runat="server"/>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" SetFocusOnError="true"  runat="server"
             ErrorMessage="error on textbox 3"  ControlToValidate="textbox3" ForeColor= "Red" ValidationGroup="main">*</asp:RequiredFieldValidator>
    </content>
    </asp:AccordionPane>
    </asp:accordion>
    //the rest of the code here
    //i typed this up, so please forgive if not everything is case sensitive

in this case, if i am on the first Pane, and click on the "validate" button, the required fields are in the second and third panes. the validation does fail, like it should, but the user is not taken to the textbox2 or textox3 (which are empty). how can i code it so that the focus is automatically set to the next failed textbox when the validation fails? it does work if i already have pane 2 open when i click on the "validate" button, in which case the focus is set to textbox2. but then again, if i put something in textbox2 and validate again, textbox3 fails, but the focus is not set.

hope this makes sense.

Guru Kara
  • 6,272
  • 3
  • 39
  • 50
Madam Zu Zu
  • 6,437
  • 19
  • 83
  • 129

1 Answers1

0

Its not strait forward to keep open two accordion panel at a time. Basically that control was not designed that way. You can use the collapsible panels instead. But this article specifies a way to do that

http://www.c-sharpcorner.com/uploadfile/Zhenia/keeping-multiple-panes-open-in-accordion-web-control/

Also here are the link to open accordion panels using JavaScript.

http://forums.asp.net/t/1194270.aspx

jQuery Accordion - open specific section on pageload

Hope this helps

Community
  • 1
  • 1
Guru Kara
  • 6,272
  • 3
  • 39
  • 50