문제

i am 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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top