1. add image,css,or javascript files into a project;
2. make them build action as embed resource;
3. add assembly entry in to AssemblyInfo.vb like:
or
the second one is to generate a macro.
4.using getresourceurl to get the resource;
here is the example:
test.js:
function alertme(){
document.write("<img src='/<%=WebResource("myobj.myimage.gif")%>'>");
}
AssemblyInfo.vb:
Test page:
Dim cs As ClientScriptManager = Page.ClientScript
Dim img As New System.Web.UI.WebControls.Image
Dim s As String = cs.GetWebResourceUrl(Me.GetType, "myobj.myimage.gif")
img.ImageUrl = s
img.Attributes.Add("onclick", "alertme();")
Page.Controls.Add(im)
those above will display the image in a page.
No comments:
Post a Comment