Click here to Skip to main content
15,608,157 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using a bootstrap popup modal and i would like to pass an image
link from the database after the user press the button to that popup window.
the debugger shows that everything is fine and the src is getting the image value
but the popup doesnt shows the image.

i thing i need some ajax script to accomplish that, please help. code:

<asp:Button ID="btn1" type="button" runat="server" Text="test"
OnClick="Click_Me" data-toggle="modal"
class="btn btn-primary"/>

<div class="modal fade" id="modal_10" tabindex="-1" role="dialog" aria-labelledby="ModalLabel_10" aria-hidden="true">
<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="ModalLabel_10">Modal title</h4>
<div class="modal-body" id="modals">
<img class="img-rounded" id="modal_Img" runat="server" src='<%# Eval("image_path","~/{0}")%>' style="height:50px; width:50px;" />
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save</button>


protected void Click_Me(object sender, EventArgs e)
        //Display modal_10 image inside the popup

        cmd = new SqlCommand("select top(1) image_path from Images", con);
        dr = cmd.ExecuteReader();

        while (dr.Read())
            modal_Img.Src = dr["image_path"].ToString();
Updated 5-Mar-14 2:30am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900