开发者

Using and accessing Webresource

I know this has been asked before. Yes, i did my research but it doesn't seem to be working for me so i hope you experts can help me out :)

Here's what my Project looks like

http://i.stack.imgur.com/nnPZJ.png

Yes, the Build Action is Embedded Resource. I also added this in the AssemblyInfo

Assembly: WebResource("WFL.WebResource.EXT.XXX.png", "image/png")

So now, in the default.aspx i say

Protected Sub Page_Load(ByVal sende开发者_StackOverflow中文版r As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim cs As ClientScriptManager = Page.ClientScript
        Dim strReturn As String = cs.GetWebResourceUrl(Me.GetType(), "WFL.WebResource.EXT.XXX.png")
        Dim strReturn2 As String = cs.GetWebResourceUrl(GetType(_Default), "WFL.WebResource.EXT.XXX.png")

        Image1.ImageUrl = "http://localhost" + strReturn
        Image2.ImageUrl = "http://localhost" + strReturn2

        Response.Write("http://localhost" + strReturn)
        Response.Write("http://localhost" + strReturn2)

    End Sub

But when accessing the returned URL, i get The resource cannot be found. What am i doing wrong? Thanks in advance.


This being VB and not C#, you don't need the .EXT portion in WFL.WebResource.Ext.XXX.png. That is something C# needs (to specify folder paths), but VB doesn't. You just want your namespace then resource. Try WFL.WebResource.XXX.png and see if that works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜