假如我们要使用两幅图片,并把它们编译到DLL中去。 首先我们要把这些图片的属性进行修改, 然后我们还需要以下的代码, [assembly: WebResource("WebApplication2.adobe.jpg", "image/jpg")] [assembly: WebResource("WebApplication2.img.xx.gif", "image/gif")] 这些代码可以放在AssemblyInfo.cs中,也可以放到其他地方,比如像下面这样 [assembly: WebResource("WebApplication2.adobe.jpg", "image/jpg")] [assembly: WebResource("WebApplication2.img.xx.gif", "image/gif")] namespace WebApplication2 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { this.Image1.ImageUrl = Page.ClientScript.GetWebResourceUrl(typeof(_Default), "WebApplication2.img.xx.gif"); } } } 最后在使用的时候要像上面代码中Page.ClientScript.GetWebResourceUrl那样使用。

评论