开发者

Why is script tag defined in contentPlaceHolder not being added?

开发者 https://www.devze.com 2023-03-15 15:31 出处:网络
I am trying to dynamically add some javascript to my view in a contentPlaceHolder. For some reason theis never added. The foreach logic directly beneath is run however.

I am trying to dynamically add some javascript to my view in a contentPlaceHolder. For some reason the is never added. The foreach logic directly beneath is run however.

What's with that?

  <asp:Content ID="Content3" ContentPlaceHolderID="DynamicIncludes" runat="server">

<script type="text/javascript" language="javascript">
   alert("why am I not firing?");
</script>   

<%foreach (var script in Model.DynamicIncludes)
  {%>开发者_StackOverflow中文版;

      <%=Html.ScriptTag(Url.Content(script))%>

  <%} %>
</asp:Content>


Its important to remember to actually define the contentPlaceHolder in the master page. Duh.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号