0

que と rply の機能を開発する必要があります。そのためには、要件に従ってユーザー コントロールを作成し、ユーザー コントロールの依存および送信ボタン用のテキスト ボックスを含む div を追加し、div 表示スタイルを維持します。 none と私はその div を示す返信リンクで JavaScript を呼び出します。

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SuppReview.ascx.cs" Inherits="LaaFoodWebApp.SuppReview" %>

<div>
    <table style="width:100%;">
        <tr>
            <td rowspan="2" style="width: 15%; vertical-align: top;">
                <asp:Label ID="lblMsgType" runat="server"></asp:Label>
                <br />
                <asp:Label ID="lblMsgId" runat="server"></asp:Label>
            </td>
            <td style="width: 70%; vertical-align: top;">
                <asp:Label ID="lblMsgtBody" runat="server"></asp:Label>
            </td>
            <td style="width: 15%">
                <asp:Label ID="lblVDate" runat="server"></asp:Label>
                <br />
                By 
                <asp:Label ID="lblname" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                <a id="toggleReply" style="color: #15ADFF" href="#">Reply</a>
            </td>
            <td>
                <asp:Label ID="lblEmail" runat="server"></asp:Label>
                <br />
                <asp:Label ID="lblPhone" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td>
            <panel id="pnlreply" >
               <div id="DivReply" style="display:none">
                <table style="width:100%;">
                    <tr>
                        <td style="width: 15%">
                           Replys</td>
                        <td>
                            <asp:TextBox ID="TextBox1" runat="server" Height="50px" TextMode="MultiLine" 
                                Width="100%"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;</td>
                        <td style="text-align: right">
                            <asp:Button ID="btnSubmit" runat="server" Text="Submit" 
                                onclick="btnSubmit_Click" />
                        </td>
                    </tr>
                    </table></div></panel>
            </td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
</div>

しかし、返信の数に応じて、それらのユーザーコントロールを複数回追加すると。

for (int i = 0; i< dt.Rows.Count; i++)
{
    SuppReview SR = (SuppReview)Page.LoadControl("SuppReview.ascx");
    SR.settxt(dt.Rows[i]);
    reviews.Controls.Add(SR);
}

ページ上

<%@ Page Title="" Language="C#" MasterPageFile="~/SupplierMasterNew.Master" AutoEventWireup="true" CodeBehind="Supp_Views.aspx.cs" Inherits="LaaFoodWebApp.Supp_Views" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
 <script type="text/javascript">
     $(function () {
         $('#toggleReply').click(function () {
             $('#DivReply').toggle('slow');
             return false;
         });
     });
      </script>     
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CPHcontent" runat="server">
    <div style="width: 100%; height: 24px; background-color: #D2EEF2; padding-top: 10px;
                font-size: large; color: #000000; text-align: left;">
        &nbsp;&nbsp;&nbsp; View</div>

    <asp:Panel ID="reviews" runat="server">

    </asp:Panel>
</asp:Content>

返信リンク int hide をクリックすると、div (依存および送信ボタンのテキスト ボックスを含む) が複数回表示され、他のエントリでは機能しません。

4

1 に答える 1

0

このコントロールを複数回追加している場合、ページに複数の重複 ID があります。

ID をクラスに変更することを検討してください。

また、コントロールの外側の div にクラスを与えてください。例えば<div class="wrapper">

関数を宣言します。

function toggleReply(sender) {
    $(sender).parent('.wrapper').children('.DivReply').toggle('slow');
}

あなたのリンク:

<a class="toggleReply" style="color: #15ADFF" href="javascript:void(0);" onclick="toggleReply(this);">Reply</a>
于 2013-08-26T13:20:43.397 に答える