我正在使用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">×</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;
}
答案 0 :(得分:0)
我通过使用隐藏字段找到了解决方案。
String