IIS 7.5 集成模式下 JavaScript 内容的新文件类型,以便呈现它
我想创建一个新的文件类型(例如 .jsrender)。在此文件中,有一些 JavaScript 代码,但也有一些代码块,例如 <%= txt1.ClientID %>
,必须在输出之前呈现这些代码块。
我怎样才能实现这个功能?另外,如何参考呢?我可以执行以下操作吗?
<script type="text/javascript" src="scripts/myjs.jsrender" runat="server" />
它会起作用吗?
另外,我将从代码隐藏文件中引用它,如下所示:
ScriptManager.RegisterStartupScript(
this.Page,
typeof(Page),
"JQueryUITimepickerAddonAjaxminJs",
String.Format("<script src='{0}' type='text/javascript' defer='defer'></script>",
ResolveUrl("~/Scripts/timepicker_addon/jquery-ui-timepicker-addon.ajaxmin.jsrender")),
false);
您认为它会在输出之前渲染吗?
我知道我们可以为 IIS 创建 HttpModule,但我不知道如何实现这种功能。
谢谢!
I want to create a new file type (for example .jsrender). Inside this file, there is some JavaScript code, but also some code nuggets like <%= txt1.ClientID %>
that have to be rendered before it's outputted.
How can I achieve this functionality? Also, how can I reference it? Can I do the following?
<script type="text/javascript" src="scripts/myjs.jsrender" runat="server" />
Will it work?
Also, I am going to reference it from code-behind file like below:
ScriptManager.RegisterStartupScript(
this.Page,
typeof(Page),
"JQueryUITimepickerAddonAjaxminJs",
String.Format("<script src='{0}' type='text/javascript' defer='defer'></script>",
ResolveUrl("~/Scripts/timepicker_addon/jquery-ui-timepicker-addon.ajaxmin.jsrender")),
false);
Do you think it will be rendered before it's outputted?
I know that we can create HttpModules for IIS, but I don't know what to do for this kind of functinality.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需将该文件扩展名映射到 ASP.Net 处理程序即可。请参阅下面的帖子来执行此操作。另请参阅他的建议,即使用重写来动态更改文件扩展名。
如何使用 .Net 处理程序处理 .asp 扩展名?
You just need to map that file extension to the ASP.Net handler. See the post below for doing that. Also look at his recommendation to use a rewrite to to just change the file extension dynamically.
How do I process .asp extensions using the .Net handler?