Search code examples
cssasp.netwebformstelerikwebresource.axd

Custom ASP Control Library - CSS Webresources not working


I made a Custom Control DLL which extend existing Telerik and ASP controls. Therefore I also created new CSS classes. Some of them use images and these images cant be loaded in the main project.

Infos:
Microsoft .NET Framework-Version:4.0.30319
ASP.NET-Version:4.8.4001.0
Telerik UI for Ajax 2014Q1
ASP Webforms

What I did:
1. Included the files (css and images) in the AssemblyInfo
2. Set PerformSubstitution = true for the css file
3. Set the Build Action for the images and the css file to Embedded Resource
4. Replaced the image paths in the css file with WebResource paths
5. Compiled Library and set it into my library directory in the main project
6. Add the controls in the web.config

AssemblyInfo.cs

//Css 
[assembly: WebResource("css.myCss.css", "text/css", PerformSubstitution = true)]

//Css related pictures
[assembly: WebResource("css.images.myImage.png", "image/png")]

myCss.css

.myCssClass{
        background-image: url('<%=WebResource("myProject.css.images.myImage.png")%>');
}

web.config

<configuration>
  <system.web>
    <pages>
      <controls>
        <add tagPrefix="myControls" assembly="myProject" namespace="myProject" />
        ... 
      </controls>
    </pages>
  </system.web>
</configuration>

The WebResource.axd http requests for my control respond with a 404. The telerik requests work fine. What do i have to do , to make those images work?

Thanks in advance, Lifree


Solution

  • I solved it... I had to add myProject in the AssemblyInfo:

    //Css 
    [assembly: WebResource("myProject.css.myCss.css", "text/css", PerformSubstitution = true)]
    
    //Css related pictures
    [assembly: WebResource("myProject.css.images.myImage.png", "image/png")]
    

    I already had this in an earlier version, but it was also missing in a tutorial i found. In combination with two other small errors i didn't thought of it again.