一个“异步”属性添加到JS包括标签在asp.net web表单 [英] Add an 'async' attribute to a JS include tag in asp.net web forms
本文介绍了一个“异步”属性添加到JS包括标签在asp.net web表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到它如何在MVC来完成,但对于具体的项目中,我使用Web表单。
I saw how it can be done in MVC, but for a specific project I'm using Web-Forms.
我
<asp:PlaceHolder ID="PlaceHolder1" runat="server">
<%: System.Web.Optimization.Scripts.Render("~/file.js") %>
</asp:PlaceHolder>
这生成HTML:
which generates the html:
<script src="/file.js?v=5jui8vHEj5_iAkaGiAccPPb2LcsdK1jQ1"></script>
我要同步属性添加到上面的标签。
I wish to add the sync attribute to the above tag.
我倒是AP preciate一些指导。谢谢你。
I'd appreciate some guidance. Thanks.
推荐答案
您可以使用RenderFormat来实现这一点:
You can use RenderFormat to achieve this:
<%: System.Web.Optimization.Scripts.RenderFormat ("<script src='{0}' async ></script>", "~/file.js") %>
呈现为:&LT;脚本的src =/ file.js异步=&GT;&LT; / SCRIPT&GT;
这篇关于一个“异步”属性添加到JS包括标签在asp.net web表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文