如何在ASP .NET中发送div上的背景图像? [英] How to send background image on div in ASP .NET?

查看:70
本文介绍了如何在ASP .NET中发送div上的背景图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发送的是带有asp .net图像的电子邮件,但是无法将图像作为div背景发送?



我尝试了什么:



I am sending Email with images in asp .net but not able to send image as div background?

What I have tried:

<pre lang="text">
<img src="cid:image1" />
<div style="background-image:url(cid:image2)">
<p>This is Text!</p>
</div>
</pre>










Email Code.

string image1Path= HttpContext.Current.Server.MapPath(@"~/Images/image1.png");
string image2Path= HttpContext.Current.Server.MapPath(@"~/Images/image2.png");

 LinkedResource lnk1= new LinkedResource(image1Path);
 LinkedResource lnk2= new LinkedResource(image2Path);

 lnk1.ContentId = "image1";
 lnk2.ContentId = "image2";

AlternateView av1 = AlternateView.CreateAlternateViewFromString("" + htmlTemplate, null, MediaTypeNames.Text.Html);
      

av1.LinkedResources.Add(image1);
av1.LinkedResources.Add(image2);
       
message.AlternateViews.Add(av1);

推荐答案

将光标放在div标签上并按F4和在该背景设置图像中的属性样式
Put Cursor on div tag and press F4 and in properties style in that background set image


我认为您错过了 background-image css属性。
I think you missed background-image css property.






您是否调试过代码,从路径中获取图像?
Hi,

Have you debugged the code, R u getting image from the path?


这篇关于如何在ASP .NET中发送div上的背景图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆