简体   繁体   English

自定义ASP控件库-CSS Webresources无法正常工作

[英]Custom ASP Control Library - CSS Webresources not working

I made a Custom Control DLL which extend existing Telerik and ASP controls. 我制作了一个自定义控件DLL,用于扩展现有的Telerik和ASP控件。 Therefore I also created new CSS classes. 因此,我还创建了新的CSS类。 Some of them use images and these images cant be loaded in the main project. 其中一些使用图像,并且这些图像无法加载到主项目中。

Infos: 资讯:
Microsoft .NET Framework-Version:4.0.30319 Microsoft .NET Framework版本:4.0.30319
ASP.NET-Version:4.8.4001.0 ASP.NET版本:4.8.4001.0
Telerik UI for Ajax 2014Q1 适用于Ajax 2014Q1的Telerik UI
ASP Webforms ASP Web表单

What I did: 我做了什么:
1. Included the files (css and images) in the AssemblyInfo 1.在AssemblyInfo中包括文件(css和图像)
2. Set PerformSubstitution = true for the css file 2.为css文件设置PerformSubstitution = true
3. Set the Build Action for the images and the css file to Embedded Resource 3.将图像和css文件的“ Build Action设置为“ Embedded Resource
4. Replaced the image paths in the css file with WebResource paths 4.用WebResource路径替换css文件中的图像路径
5. Compiled Library and set it into my library directory in the main project 5.编译的库并将其设置到主项目的我的库目录中
6. Add the controls in the web.config 6.在web.config中添加控件

AssemblyInfo.cs 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 myCss.css

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

web.config 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 . 对我的控件的WebResource.axd http请求以404响应。 The telerik requests work fine. telerik请求工作正常。 What do i have to do , to make those images work? 为了使这些图像正常工作,我该怎么办?

Thanks in advance, Lifree 在此先感谢Lifree

I solved it... I had to add myProject in the AssemblyInfo : 我解决了...我必须在AssemblyInfo添加myProject

//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. 结合其他两个小错误,我再也没有想到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM