How to pass the linkbutton text to the modal popup. Now Im only getting a empty popup

<script type="text/javascript">
$("#linkbutton1").click(function(){ 
var text =$("#linkbutton1).val();
$("#modal_body").html(text);
});
function openModal() {
    $("#myModal").modal('show');
    }
</script>
<div>
    <div id="myModal" class="modal fade" role="dialog">
        <div class="modal-dialog">
            <div class="modal-content">
               <div class="modal-header">
                 <h4 class="modal-title">
                        Modal Title</h4>
                </div>
                <div class="modal-body">
                <p id="modal_body" runat="server"></p>
         </div>
                <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div></div></div></div>


<asp:GridView>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton id="linkbutton1" runat="server" Text='<%#Eval("Content").ToString().Length>10 ? Eval("Content").ToString().Substring(0,10): Eval("Content").ToString()%>'
CommandArgument='<%#Eval("Content")%>' data-toggle="modal" data-target="#myModal" >
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</asp:GridView>

Remove the entire <script> section in the code you posted and instead use this:

<script type="text/javascript">
// This executes right before displaying the modal
$('#myModal).on('show.bs.modal', function (event) {
    var text = $("#linkbutton1").text();
    $("#modal_body").html(text);
});
</script>

There's no need for the openModal() function because you're not using it anywhere anyways.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.