Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取jquery模式弹出窗口中asp:repeater中标签的值_Jquery_Asp.net - Fatal编程技术网

获取jquery模式弹出窗口中asp:repeater中标签的值

获取jquery模式弹出窗口中asp:repeater中标签的值,jquery,asp.net,Jquery,Asp.net,我试图在jquery弹出窗口中获取asp:reader中标签的值。我已经测试了这个教程,效果很好。但是,当我尝试在脚本中使用相同的概念时,没有显示任何数据。我已经查看了后面的代码,其中有一些值。这是我的剧本 <script type="text/javascript"> $(document).ready(function () { $("#btnclickedit").click(function () { var currentRo

我试图在jquery弹出窗口中获取asp:reader中标签的值。我已经测试了这个教程,效果很好。但是,当我尝试在脚本中使用相同的概念时,没有显示任何数据。我已经查看了后面的代码,其中有一些值。这是我的剧本

<script type="text/javascript">
    $(document).ready(function () {
        $("#btnclickedit").click(function () {
            var currentRow = $(this).parents("tr");
            var MBBody = currentRow.find("span[id*='messageBody']").text();
            $("#ContentPlaceHolder1_bmessageedit").text(MBBody);
            $("#divpopupedit").dialog({
                width: 600,
                height: 580,
                title: "Edit a Message",
                modal: true,
            });
        });
    })
</script>

<div id="divpopupedit" style="display: none">
    <div class="form-group">
        <label for="BodyMessage">Reply:</label><br />
        <asp:Label ID="bmessageedit" runat="server" />
        <asp:HiddenField ID="MessageBoardIDEdit" runat="server" />
    </div>
</div>
<asp:Repeater ID="myRepeater" OnItemDataBound="myRepeater_ItemDataBound" runat="server">
    <HeaderTemplate>
        <div class="messageBox">
            <table id="messageDetails">
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <td>
                <asp:Label ID="title" Font-Bold="true" Text='<%# Eval("MessageTitle") %>' runat="server" />
                <span class="subtitle">Posted By: <%# Eval("EmployeeName") %> | <%# Eval("DateTimePosted") %> </span><span id="messageED" class="messageActions" runat="server">
                    <button type="button" class="ui-button ui-widget ui-corner-all" id="btnclickedit">Edit</button>
                    |
                    <button type="button" class="ui-button ui-widget ui-corner-all" id="btnclickdelete">Delete</button>
                </span>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="messageBody" Text='<%# Eval("Message") %>' runat="server" />
                <asp:HiddenField ID="MBCategoryID" Value='<%# Eval("MBCategoryID") %>' runat="server" />
                <asp:HiddenField ID="PostedBy" Value='<%# Eval("PostedBy") %>' runat="server" />
                <asp:HiddenField ID="MessageBoardID" Value='<%# Eval("MessageBoardID") %>' runat="server" />
            </td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
            </div>
    </FooterTemplate>
</asp:Repeater>

我将首先使用
,而不是
id
来识别中继器中单击的按钮。(请注意,在中继器中有多个
id=“btnclickedit”
实例,因此无论如何都不起作用

然后在javascript中,您将在同一个
tr
中查找
messageBody
,但它在下一个中

因此,将按钮更改为此,并添加一个唯一的类名
btnclickedit

<button type="button" class="ui-button ui-widget ui-corner-all btnclickedit" id="btnclickedit">Edit</button>
现在,将脚本修改为

<script type="text/javascript">
    $(document).ready(function () {
        $('.btnclickedit').click(function () {
            var currentRow = $(this).closest('tr');
            var MBBody = currentRow.next('tr').find('.messageBody').text();

            ....
        });
    });
</script>
最好使用ClientID,尤其是在使用母版页时

$("#<%= bmessageedit.ClientID %>").text(MBBody);
$(“#”)文本(MBBody);

或者,如果您不需要ASP功能,请将其设置为“普通”div。

您是否尝试设置断点?您在哪里解析来自数据库和
$(“#contentplaceholder 1_MessageID”).val()的结果
这是做什么的?你想给这个值分配什么文本框
string MessageID
这是用来做什么的?我想你应该先异步返回数据,然后显示一个模式弹出窗口并取出async:false部分,你说你不能显示数据,并且有数据..但我看到你返回的唯一一件事是“True”通过web方法,您是否考虑过返回datatable?@MethodMan我按照建议创建了一个datatable,但在两个文本框中仍然没有返回任何数据。当我在success函数中执行警报时,我会收到一个带有值的响应,但它不会显示在文本框中。您正在尝试的文本框ID或名称是什么要填充?您需要将为Message和MessageID分配的值分开,但您仍然没有正确显示如何从中分配数据postback@MethodMan我正在尝试填充两个文本框MessageID和Message。如何区分这些值?
<script type="text/javascript">
    $(document).ready(function () {
        $('.btnclickedit').click(function () {
            var currentRow = $(this).closest('tr');
            var MBBody = currentRow.next('tr').find('.messageBody').text();

            ....
        });
    });
</script>
$("#ContentPlaceHolder1_bmessageedit").text(MBBody);
$("#<%= bmessageedit.ClientID %>").text(MBBody);