.Net 2.0 - WebResource attribute with css file

V

Vesa Juvonen

Hi,

I'm developing a custom control using VS2005. The control has embedded
resources with it (js, images and css) and when control is rendered to page,
it uses the GetWebResourceUrl funtion to get correct address for the
resources (resources are streamed directly from assembly using
WebResource.axd).



Everything works well with images and javascript files, but for some reason
the css files are not streamed correctly. Is this a restrictions in the
HttpHandler, or something else?





In this case the web site level Themes or css files are not an option (these
are not suitable for reusable control development). Of course the css
attributes could be applied to each html element individually, but this
would cause repeating the style attributes for each element, which would
cause the page sizes to increase unnecessarely.





Sample code to demostrate

-----------------------------------------

-- Code snipped for the Images - Works well --



Embedded image in assembly named as foo.gif

<Assembly: WebResource("foo.gif", "image/gif")> - As a assembly attribute

Me.Page.ClientScript.GetWebResourceUrl Me.GetType, "foo.gif") - for img src



Let's put the link address of image (from client side page) to browser
address box: We can see the image from the assembly.





-- Code snipped for the Images - does not work --

Embedded css in assembly named as BWVerticalMenu.css

<Assembly: WebResource("foo.css", "text/css")>

Me.Page.ClientScript.GetWebResourceUrl Me.GetType, "foo.css") - for htmllink
href property



Let's put the link address of css file (from client side page) to browser
address box: We get empty html page... which was not expected.We would like
to have the css file as in the image case.





--

There's an excellent article concerning this functionality in te MSDN
including sample files:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/webresource.asp



However the samples provided in this article don't work with the released
version of VS2005 (built on earlier version), due minor changes in class
members. f.ex the LinkedStyleSheet is no more accessable from the controls
in the page, since the function has been swithed to protected. Well. in
sense ot current problem, this is not the issues, since we can by pass this
problem using Header.Controls collection and HtmlLink class.

--





Thanks in Advance

- Vsku
 
B

Brock Allen

The only thing I can think of off the top of my head is if the CSS is not
marked as an embedded resource in your assembly. Use reflector and open your
assembly and check the resources to see if it's even there, and then if it
is to make sure the name you're using is correct.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top