使用图片显示公司详细信息, 我有控制器:
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);
}
和功能:
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;
}
它显示所有其他数据,但不显示image.please你能说出这个想法吗?
答案 0 :(得分:0)
我想你忘了关闭img tag.Check it曾经可以帮助你。
<img src="' + headdata.LogoFileName + '" width=50 height=50 />