JavaScript在转发器中切换

时间:2013-10-10 03:45:43

标签: javascript asp.net

在转发器中,当我点击row1时,它正在展开,当我点击row2时,row1正在崩溃,row2正在展开。

但是,当我单击row1(类标题)时,我会再次单击row1,但是当它再次单击row1时,它也必须折叠。那不行。

    <style>
   .header { font-size: larger; font-weight: bold; cursor: hand; cursor:pointer;
       background-color:#cccccc; font-family: Verdana; }
   .details { display:none; visibility:hidden; 
         font-family: Verdana; }
    </style>
 <SCRIPT>
     function ToggleDisplay(id) {
    var allDetails = document.getElementsByClassName('details');
    var detaisToShow = document.getElementById('d' + id);
    for(var i=0; i<allDetails.length; i++){
        allDetails[i].style.display = 'none';
        allDetails[i].style.visibility = 'hidden';
    }
    detaisToShow.style.display = 'block';
    detaisToShow.style.visibility = 'visible';
    }

 </SCRIPT>
<style>
    .header { font-size: larger; font-weight: bold; cursor: hand; cursor:pointer;
       background-color:#cccccc; font-family: Verdana; }
  .details { display:none; visibility:hidden; 
         font-family: Verdana; }
</style>

    &nbsp;<div style="overflow: scroll; overflow-x: hidden; overflow-y: auto;background-color:gray;  height: 500px; width: 895px">

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">

         <ItemTemplate>


 <div id='h<%# DataBinder.Eval(Container, "ItemIndex") %>' class="header"
      onclick='ToggleDisplay(<%# DataBinder.Eval(Container, "ItemIndex") %>);' style="border- style: none;">
     <asp:Panel ID="Panel3" runat="server" Height="30px" BorderStyle="None" BackColor="#79FFFF">

    <%# DataBinder.Eval(Container.DataItem, "License")%> 
   <%# DataBinder.Eval(Container.DataItem, "Name")%>

  <%# DataBinder.Eval(Container.DataItem," Date")%>
  </asp:Panel> 
 </div>

<div id='d<%# DataBinder.Eval(Container, "ItemIndex") %>' class="details">

  <asp:Panel ID="Panel2" runat="server" Height="195px" BackColor="Gray" Font-Bold="False"  ForeColor="Maroon">
  <br />
      <asp:Label ID="Label1" runat="server" Text="LicenseID"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;

                <asp:TextBox ID="TextBox1" runat="server" Text='<%# DataBinder.Eval  (Container.DataItem,"LicenseID") %>' Enabled="False" BackColor="Gray"   BorderStyle="None"></asp:TextBox>
      <asp:Label ID="Label2" runat="server" Text="License Name"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"LicenseName")%>' Enabled="false" BackColor="Gray" BorderStyle="None"></asp:TextBox>

            </asp:Panel>

 </div>

        </ItemTemplate>

0 个答案:

没有答案