簡體   English   中英

回發后如何保持折疊的div為打開狀態

[英]how to keep collapsed div as open after postback

以下是我的Javascript,用於在asp.net中展開/折疊gridview行

<script type="text/javascript">
    function divexpandcollapse(divname) {
        var div = document.getElementById(divname);
        var img = document.getElementById('img' + divname);
        if (div.style.display == "none") {
            div.style.display = "inline";
            img.src = "Img1/minus.gif";
        } else {
            div.style.display = "none";
            img.src = "Img1/plus.gif";
        }
    }
</script>

這是我的gridview templatefield

        <asp:TemplateField>
            <ItemTemplate>
                <a href="JavaScript:divexpandcollapse('div<%# Eval("ClaimMasterId") %>');">
                    <img id='imgdiv<%# Eval("ClaimMasterId") %>' width="9px" border="0" src="Img1/plus.gif" alt="" title="Add Action Notes" /></a>                        
            </ItemTemplate>
            <ItemStyle Width="10px" VerticalAlign="Middle"></ItemStyle>
        </asp:TemplateField>


        <asp:TemplateField>
            <ItemTemplate>
                <tr>
                   <td colspan="100%" style="background:#F5F5F5">
                       <div id='div<%# Eval("ClaimMasterId") %>'  style="overflow:auto; display:none; position: relative; left: 15px; overflow: auto;">
                           <div style="width:900px; -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175); box-shadow: 0 6px 12px rgba(0,0,0,.175); -moz-box-shadow: 0 6px 12px rgba(0,0,0,.175);">
                       <table>
                           <tr>
                               <td style="vertical-align:top">
                                    <asp:RadioButtonList ID="MoveToRBL" runat="server" RepeatDirection="Horizontal" AutoPostBack="true" OnSelectedIndexChanged="MoveToRBL_SelectedIndexChanged" >
                                        <asp:ListItem Text="Review" Value="Review" Selected="True"></asp:ListItem>
                                        <asp:ListItem Text="Call" Value="Call"></asp:ListItem>
                                        <asp:ListItem Text="Re-Call" Value="ReCall"></asp:ListItem>
                                        <asp:ListItem Text="Audit" Value="Audit"></asp:ListItem>
                                    </asp:RadioButtonList>&nbsp;&nbsp;
                               </td>
                               <td style="vertical-align:top">
                                   <asp:ImageButton ID="SaveButton" runat="server" ImageUrl="~/Img1/save32.png" ToolTip="Save" OnClick="SaveButton_Click" />
                               </td>
                           </tr>
                       </table>
                               </div>
                       </div>                     
                    </td>
                </tr>
            </ItemTemplate>
            <ItemStyle Width="1px" ></ItemStyle>
        </asp:TemplateField>

展開和折疊工作正常,但是每當單擊RadioButttonList“ MoveToRBL”時,展開的div就會折疊。 然后,我需要再次單擊加號以展開它。 為什么會發生,如何阻止它。 我需要在Javascript中進行任何更改,請告訴我。

通過條件模式的UpdatePanel實現,如下所示。

<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:DropDownList ID="AllocateToDDL" runat="server" CssClass="dropdown" Visible="true" Width="135px" AppendDataBoundItems="True" DataSourceID="GetARmembers" DataTextField="EmpName" DataValueField="EmpName" >
<asp:ListItem Text="Select the Caller" Value="NA" Selected="True"></asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="MoveToRBL" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM