To display company details with image, I have controller like:
public JsonResult PrintHeading()
{
CompanyModel cm = new CompanyModel();
string qry = "select CompanyName,Address,ContactNo,EmailAddress,LogoFileName from tblCompanyInfo";
DataTable dt = cls.LoadData(qry);
foreach (DataRow dr in dt.Rows)
{
cm.CompanyName = Convert.ToString(dr["CompanyName"]);
cm.Address = Convert.ToString(dr["Address"]);
cm.ContactNo = Convert.ToString(dr["ContactNo"]);
cm.EmailAddress = Convert.ToString(dr["EmailAddress"]);
cm.LogoFileName = Path.Combine("\\Content\\Logo", Convert.ToString(dr["LogoFileName"]));
}
return Json(cm, JsonRequestBehavior.AllowGet);
}
and Function:
function getPrintHeading() {
var heading = '';
$.ajax({
url: '@Url.Content("~/Bank/PrintHeading")',
type: "GET",
dataType: "JSON",
async: false,
success: function (headdata) {
heading = '<img src="' + headdata.LogoFileName + '" width=50 height=50>' + headdata.CompanyName + '<br>' + headdata.Address + '<br>' + headdata.ContactNo + ', ' + headdata.EmailAddress ;
}
});
return heading;
}
It displays all other data but doesn't display image.please Can you give the idea?
我认为您忘记了关闭img标签。检查一次可能会对您有所帮助。
<img src="' + headdata.LogoFileName + '" width=50 height=50 />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.