Set the value of the text field in Bootstrap Modal from the label text

I show bootstrap modal when I click on the hyperlink. In addition to the hyperlink, there is a shortcut in which some text is printed dynamically.

I get the text of this particular label using jquery to print it in the text box present in Bootstrap Modal.

The text is extracted very well, but I could not succeed, showing that this text is a bootable modular text field.

Here is my jQuery code:

<script>
    $(function () {
        $(".edit").click(function () {    
            var tr = $(this).parent().parent();
            var tdRecords = $(tr).children();
            var CurrValue = $(tdRecords[0]).text();
            var NewValue = $(tdRecords[1]).text();
            alert(CurrValue); //alert is showing the value fine
            $("#Curr_Val").val(CurrValue); //not working
            $('#myModal').modal('show');
        });
    });
</script>

Here is my modal code:

<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Edit Information</h4>
            </div>
            <div class="modal-body">
              <div class="row">
                  <div class="col-md-3">
                      Current Value :
                  </div>
                  <div class="col-md-6">
                      <asp:TextBox CssClass="txtstyle" runat="server" ID="Curr_Val"></asp:TextBox>
                  </div>
              </div>
                <div class="row">
                  <div class="col-md-3">
                      New Value :
                  </div>
                  <div class="col-md-6">
                      <asp:TextBox CssClass="txtstyle" runat="server" ID="New_Val"></asp:TextBox>
                  </div>
              </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary">Save Changes</button>
                <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
            </div>

        </div>
    </div>
</div>

The value printed in the warning is very good, but it does not print in the text box.

Someone please help me what I am missing.

Thanks in advance

+4
1

asp net, jquery. $('#<%= Curr_Val.ClientID %>').val(CurrValue);

+4

All Articles