I tried to figure out where i got this code wrong but couldnt, the jquery modal pop by button click in datalist is
poping up well but the content like the image is not showing, the modal is showing empty modal.
[WebMethod]
public static List<Banner> GetBannerDetails(int id)
{
string constrr = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
using (SqlConnection con = new SqlConnection(constrr))
{
using (SqlCommand cmd = new SqlCommand("Gettimelinebanner"))
{
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
// cmd.Parameters.AddWithValue("@UserName", HttpContext.Current.Session["userName"].ToString());
cmd.Parameters.AddWithValue("@UserId", id);
List<Banner> banners = new List<Banner>();
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
banners.Add(new Banner {
UserId = sdr["UserId"].ToString(),
Name = sdr["Name"].ToString(),
ImageName = sdr["ImageName"].ToString() });
}
con.Close();
return banners;
}
}
}
html Datalist
============================================================================================================
<asp:DataList ID="Repeater1" runat="server" RepeatColumns="3" RepeatDirection="Horizontal" Width="100%">
<ItemTemplate>
<span class="" style=" ">
<a >
<asp:LinkButton ID="lnksummery" runat="server">
<asp:Label ID="lblUserId" Text='<%#Eval("UserId") %>' runat="server" Font-Size="0px"/>
<asp:Image ID="Imagfollowers" Text='<%#Eval("ImageName")%>' runat="server" src='<%#getSRCCLUBPHOTOS(Container.DataItem)%>'
class="followerimg img-rounded" Style="background-repeat: no-repeat;border-color:Silver;border-width:1px;border-style:Solid;"
alt="" data-aria-label-part="" background-image='<%# ("PROFILEPHOTOS/") %>' height="93px" width="93px" />
</asp:LinkButton></a></span></ItemTemplate></asp:DataList>
Modal markup
=================================================================
<div class="modal fade" id="myModalprofilepopup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<asp:Image ID="ImageName" runat="server" ImageUrl='<%# String.Format("PROFILEPHOTOS/{0}",Eval("ImageName").ToString()) %>'
class="imagename" Style="width:100%" />
<div id="" class="modal-body">
<span class="name" style="font-family: Arial, Helvetica, sans-serif; font-weight: bold">
<%# Eval("Name") %></span>
<span class="id" style="font-size:0; color: #FFFFFF">
<%# Eval("UserId") %></span>
<div class="modal-footer">
</div>
</div></div></div></div>
====================================================
Jquery
</script><script type="text/javascript">
$(function () {
// lnksummery click
$('[id*=lnkbtfollowsummery]').on('click', function () {
var id = $(this).closest('tr').find($('[id*=lblUserId]')).text();
$.ajax({
type: "POST",
url: "Timeline.aspx/GetBannerDetails",
data: '{id:"' + id + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
// clear old value
$(".name").html('');
$(".id").html('');
$(".imagename").attr('src', '');
// Assign new value
if (response.d.length > 0) {
$(".id").html(response.d[0].UserId);
$(".name").html(response.d[0].Name);
$(".imagename").attr('src', 'PROFILEPHOTOS/' + response.d[0].ImageName);
}
$('#myModalprofilepopup').modal('show');
},
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
return false;
});
});
</script>