[英]Fixing the SubSonic 2.2 Calendar, How do I get RegisterClientScriptInclude calls to render when control is not visible?
[英]How do I add an attribute to the script tag when using RegisterClientScriptInclude in c#
我試圖像這樣使用時讓我的腳本標簽包含屬性defer="true"
string path = "~/scripts/v_wall.js";
Page.ClientScript.RegisterClientScriptInclude(typeof(SlideShow), "defaultslideshow", ResolveUrl(path));
如何讓這種方法像這樣渲染腳本標簽?
<script defer = "true" type="text/javascript">
<!-- etc... -->
</script>
非常感謝!
為什么不使用方法RegisterClientScriptBlock代替呢? http://msdn.microsoft.com/zh-CN/library/btf44dc9.aspx
我想應該是這樣。
string scriptstr = "<script defer='true' type='' src=''></script>";
Page.ClientScript.RegisterClientScriptBlock(typeof(SlideShow), "defaultslideshow", scriptstr);
祝好運
我認為您將需要自己發出腳本標簽。 為了盡快將其添加到頁面中,以防頁面中的某些內容需要盡快使用javascript。
為此,您可以將它們添加到頁面標題中:
var sbText = new System.Text.StringBuilder(500);
// ToDo: Add your script to the textbuilder here
this.Page.Header.Controls.Add(New LiteralControl(sbText.ToString()));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.