通过单击按钮获取jquery分配的标签值

时间:2016-08-26 16:11:41

标签: c# jquery twitter-bootstrap-3

我正在使用Bootstrap v3.3 Modal并使用jquery为标签赋值,如何在c#中使用button_click获取指定标签的值? 我可以将值传递给文本框,我可以从文本框中获取值,但不能从标签中获取值。 我使用以下代码。

<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
   <div class="modal-dialog" role="document">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
               <h4 class="modal-title" id="exampleModalLabel" runat="server"></h4>
         </div>
         <div class="modal-body">
            <div class="form-group">
               <label for="recipient-name" id="lblOldValue" class="control-label" runat="server">Brand:</label>
               <asp:TextBox ID="txtUpdate" runat="server" class="form-control"></asp:TextBox>
            </div>
         </div>
         <div class="modal-footer">
            <asp:Button ID="btnUpdate" runat="server" class="btn btn-primary" Text="Save" OnClick="btnUpdate_Click"/>
         </div>
      </div>
   </div>
</div>


$('#exampleModal').on('show.bs.modal', function (event) {
        var button = $(event.relatedTarget); // Button that triggered the modal
        var recipient = button.data('whatever'); // Extract info from data-* attributes

        var modal = $(this);
        modal.find('.modal-title').text('Edit: ' + recipient);
        modal.find('modal-body lable').val(recipient);
        modal.find('.modal-body input').val(recipient);
    });

protected void btnUpdate_Click(object sender, EventArgs e)
{
    string newValue = txtUpdate.Text;
    string oldValue = lblOldValue.InnerText;
}

1 个答案:

答案 0 :(得分:0)

我通过使用隐藏字段找到了解决方案。

String