Hello All,
I need your help to display image from database in modal popup window in asp.net application.
I have mentioned my code for your reference.
Here my htm code:-
- <div class="modal fade" id="myModal">
- <div class=" modal-dialog modal-dialog-centered">
- <div class="modal-content">
- <div class="modal-header">
- <h4 class="modal-title">Image Details</h4>
- </div>
- <div class=" modal-body">
- <img class="img-rounded" id="modal_Img" src='<%# Eval("Image")%>' style="width: 100%" runat="server" />
- <br />
- <asp:TextBox ID="tbxComment" CssClass="text-primary" Width="350px" TextMode="MultiLine" runat="server"></asp:TextBox>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-primary" data-dismiss="modal">Save</button>
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
- </div>
- </div>
- </div>
- </div>
And below is the c# code:-
- private void LoadImageBasedOnFID(Int64 FID)
- {
- try
- {
- using (SqlCommand command = new SqlCommand("LoadImageBasedOnFID", clsConObj.sqlCon))
- {
- clsConObj.OpenConnection();
- command.Parameters.Add("@FID", SqlDbType.SmallInt).Value = FID;
- command.CommandType = CommandType.StoredProcedure;
- using (SqlDataReader reader = command.ExecuteReader())
- {
- while (reader.Read())
- {
- modal_Img.Src = reader["Image"].ToString();
- ClientScript.RegisterStartupScript(this.GetType(), "Pop", "openModal();", true);
- }
- }
- clsConObj.CloseConnection();
- }
- }
- catch (Exception ex)
- {
- }
- }