开发者

clientscript.registerclientscriptblock or include not adding to the page head?

开发者 https://www.devze.com 2022-12-19 14:29 出处:网络
i am开发者_JAVA百科 using the clientscript.registerclientscriptblock with (typeof(page),this,that) to bung in my scripts.. ie. jquery and validate etc..

i am开发者_JAVA百科 using the clientscript.registerclientscriptblock with (typeof(page),this,that) to bung in my scripts.. ie. jquery and validate etc..

and i also have some hand scripted stuff in the head (where scripts are supposed to be .. right?) doing bits and bobs..

but it seems that as the registerclientscript doesnt put the scripts in the head (goodness knows why) that the scripts i have put in by hand in the head!

surely .net has a way to put the scipts in the head..?! no?!? or am i going to have to either, dump all my hand coded stuff at the bottom of all my pages (just feels all wrong) or .. is there another answer?

thanks

nat

i truly cannot understand why the registerscriptblock/include does not put things in the head of the page... why why why - ok im sure there is a reasonable answer, but even so ?


If you're using master pages, the job is as simple as this...

<!-- in master page -->
<head>
    <link type="text/css" rel="stylesheet" href="/styles/common1.css" />
    <script type="text/javascript" src="/scripts/common1.js"></script>
    <asp:contentplaceholder id="ExtraStylesAndScripts" runat="server" />
</head>

<!-- on child pages -->
<asp:content contentplaceholderid="ExtraStylesAndScripts" runat="server">    
    <link type="text/css" rel="stylesheet" href="/styles/extra1.css" />
    <script type="text/javascript" src="/scripts/extra1.js"></script>
</asp:content>

Here's a link about custom header elements in ASP.NET

0

精彩评论

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

关注公众号