Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
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.

asp.net code:

XML
<asp:Button ID="btn1" type="button" runat="server" Text="test"
OnClick="Click_Me" data-toggle="modal"
data-target="#modal_10"
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>
<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>
<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>
</div>
</div>
</div>
</div>


c#:

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

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

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

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