在自定义服务器控件 asp.net 中嵌入图像、javascript文件

发布于 2024-08-21 12:15:45 字数 100 浏览 3 评论 0原文

我想制作一个像ajax编辑器一样的html编辑器。我的意思是说所有内容都合并在一个 dll(图像、javascript、类)中。

如何实现这一点。

请帮助

I want to make an html editor like ajax editor. I mean to say everything is merged in a single dll(images,javascript,class).

How to accomplish this.

Plz Help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

Saygoodbye 2024-08-28 12:15:45

如果您仔细阅读本文,这篇Microsoft 知识库文章对于如何执行此操作确实是一个很好的参考,您还将看到一种在基于文本的嵌入资源(如 CSS 和 JavaScript 文件)中“执行替换”的方法。 WebResource 属性有一个 PerformSubstitution 属性,如果设置为 true,将允许您在嵌入资源内使用 WebResource URL。这使您能够在嵌入的 CSS 文件中的 CSS 选择器中引用嵌入的图像。

在 AssemblyInfo 文件中,您可以像这样指定 PerformSubstitution:

[assembly: WebResource("SimpleControl.MyScript.js", "text/javascript", PerformSubstitution = true)]

在 JavaScript 文件内,您可以使用这段代码按程序集中的名称访问特定资源(命名空间和所有资源):

<%= WebResource("SimpleControl.smallSuccess.gif")%>

在一般 ASP.NET 服务器中进行默认蒙皮的控件(以 Telerik 的控件为例)将所有内容嵌入到程序集中。我在过去和当前的项目中编写了几个使用这种技术的控件,并且效果非常好。如果您的 CSS 编写正确,您甚至可以允许很好地覆盖控件外部的样式,以允许进一步自定义提供的默认值和/或外观。

This Microsoft KB article is really a good reference for how to do this and if you read this article closely, you'll also see a way to "perform substitution" within text-based embedded resources like CSS and JavaScript files as well. The WebResource attribute has a PerformSubstitution property that, if set to true, will allow you to use WebResource URLs inside of your embedded resources. This gives you the ability to reference embedded images within CSS selectors in the embedded CSS file.

In the AssemblyInfo file, you'd specify PerformSubstitution like this:

[assembly: WebResource("SimpleControl.MyScript.js", "text/javascript", PerformSubstitution = true)]

Inside the JavaScript file, you can use this bit of code to access a specific resource by name as it is in the assembly (namespace and all):

<%= WebResource("SimpleControl.smallSuccess.gif")%>

In general ASP.NET server controls that do default skinning (take Telerik's controls as an example) have everything embedded in the assembly. I have written several controls that use this technique in the past and in current projects and it works very well. If your CSS is written properly, you can even allow good overriding of the styling external to the controls to allow further customization to the provided defaults and/or skins.

夜访吸血鬼 2024-08-28 12:15:45

您可以使用 WebResourceAttribute本文可能也会有所帮助。

You could use WebResourceAttribute. This article might be helpful as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文