lundi 11 juillet 2016

ASP.NET MVC display image from json result


Image is not displaying from json result value. Below is my Controller Action and Jquery

$.post('/User/Comment/',{commentId=Id},function(data){

  $("#cbox").append("<img src="'+data.ImagePath+'" />")

});

Controller:

public ActionResult Comment(string commentId){
     var data=(from p in db.commentdb
     join q in db.profileImage
     on p.Email equals q.Email
     where p.commentId==commentId
     select new
    {
     Name=p.Fullname,
     Comment=p.Comment
     ImagePath=q.ImagePath
     });
    return Json(data,jsonrequestbehavior.allowget)
   }

Please help to fix this. Just I need to display image on razor view based on json return image path


Aucun commentaire:

Enregistrer un commentaire