none
Get the value of a textbox,dropdown inside accordion ContentTemplate using javascript

    Pertanyaan

  • Hi Guys,

    I just want to seek help on how to access the controls inside the accordion.

    I have textboxes and dropdown controls inside accordion. I want to check if those controls has value and even access those values.

    Here is my aspx

    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
         
        <cc1:Accordion ID="accordSearch" runat="server" SelectedIndex="0" HeaderCssClass="accordionHeader"
    
        HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" FadeTransitions="true"
        SuppressHeaderPostbacks="true" TransitionDuration="200" FramesPerSecond="60" RequireOpenedPane="false" AutoSize="None" >
    
        <Panes>
            <cc1:AccordionPane ID="AccordionPane1" runat="server">
                <Header>Search Multi</Header>
                <Content>
                    <div>
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <Triggers>
                            <asp:PostBackTrigger ControlID="Button1" />
                        </Triggers>
            
                        <ContentTemplate> 
                            <div>
                    <ul>
                        <li>
                            <label>Family Name</label>
                            <asp:TextBox ID="txtFamilyName" runat="server" class="required"></asp:TextBox>
                        </li> 
                        <li> 
                            <label>First Name</label><asp:TextBox ID="txtFirstName" runat="server"> </asp:TextBox>
    
                        </li>
                        <li>
                            <label>Gender</label> 
                            <asp:DropDownList ID="ddlAdp" runat="server">
                                <asp:ListItem></asp:ListItem>
                                <asp:ListItem Value="M">Male</asp:ListItem>
                                <asp:ListItem Value="F">Female</asp:ListItem>
                            </asp:DropDownList>
    
                        </li>
                    </ul>
                  </div> 
                            <asp:Button ID="Button1" runat="server" Text="Check for All NULL" 
                            OnClientClick="return tries(); return false;" onclick="Button1_Click" />
                        </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
                </Content>
            </cc1:AccordionPane> 
        </Panes>
        </cc1:Accordion>
        
        <asp:Panel ID="Panel1" runat="server" Style="display: none; background-color: #CCCCCC;">
            <img src="App_Themes/Themes/progressor.gif" alt=" "/>
            <asp:HiddenField ID="hiddenField" runat="server" />
        </asp:Panel>
        
        <cc1:ModalPopupExtender ID="ProgressBarModalPopupExtender" runat="server" TargetControlID="hiddenField" PopupControlID="Panel1"
            BackgroundCssClass="modalPopBackground" behaviorID="ProgressBarModalPopupExtender">
        </cc1:ModalPopupExtender>
        </form>
    </body>

    Here is my javascript, which cannot locate the controls inside the accordion

    function tries()
    {
        if (trim(document.getElementById('txtFamilyName').value) == '' && trim(document.getElementById('txtFirstName').value) == ''
        && document.getElementById('ddlAdp').value == 0) 
        {
            alert('Please select atleast 1 criteria');
            return false;        
        }
    Thank you very much.

    Christian

    27 April 2012 3:53

Semua Balasan