使用Javascript在嵌套的FormView中进行HIde / Show控件

时间:2016-03-12 14:34:17

标签: javascript asp.net

Up on Editing我想在使用javascript检查MYCheckBox时隐藏MyTextBox。我可以使用

在ParentFormView中找到confrols
var MyTextboxINParentFV= document.getElementById('<%=ParentFormView.FindControl("MyTextboxINParentFV").ClientID %>');

但到现在为止我无法在ChildFormView中获得控件,任何人都能帮帮我吗?

<asp:formview ID="ParentFormview" runat="server">
   <ItemTemplate>
                <asp:TextBox  ID="MyTextBoxInParentFV" runat="server"></asp:TextBox>
                 <asp:CheckBox ID="MYCheckBoxInParentFV" runat="server"></asp:CheckBox>    
       <asp:FormView ID ="ChildFormView1" runat="server">
           <ItemTemplate>
                <asp:TextBox  ID="MyTextBoxInChildFV" runat="server"></asp:TextBox>
                 <asp:CheckBox ID="MYCheckBoxInChildFV" runat="server"></asp:CheckBox>
           </ItemTemplate>
       </asp:FormView>
   </ItemTemplate>
     <EditItemTemplate>
         <asp:TextBox  ID="MyTextBoxInParentFv" runat="server"></asp:TextBox>
                 <asp:CheckBox ID="MYCheckBoxInParentFV" runat="server"></asp:CheckBox> 
         <asp:FormView ID="ChildFormView2" runat="server">
             <EditItemTemplate>
                <asp:TextBox  ID="MyTextBoxInChildFV" runat="server"></asp:TextBox>
                 <asp:CheckBox ID="MYCheckBoxInChildFV" runat="server"></asp:CheckBox>
             </EditItemTemplate>            
         </asp:FormView>
    </EditItemTemplate>   
</asp:formview>

1 个答案:

答案 0 :(得分:0)

您可以将类名设置为内部FormView的控件:

   $sql = "INSERT INTO time (min) VALUES ($min)

并使用该类名检索它们:

<asp:FormView ID ="ChildFormView1" runat="server">
   <ItemTemplate>
       <asp:TextBox  ID="MyTextBoxInChildFV" runat="server" CssClass="childTextBox"></asp:TextBox>
       <asp:CheckBox ID="MYCheckBoxInChildFV" runat="server" CssClass="childCheckBox"></asp:CheckBox>
   </ItemTemplate>
</asp:FormView>