views:

334

answers:

1

Hai guys, How to include inline jquery scripts used in an aspx to a separate js file with asp.net master pages

+1  A: 

Your masterpage can have a script link to the core Jquery file:

<html>
<head runat="server" >
    <title>Master page title</title>
    //link to Jquery script
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
    <asp:contentplaceholder id="Head" runat="server" />
</head>
<body>
.
<asp:contentplaceholder id="Main" runat="server" />
.
</body>

ASPX page can have other script links specific to the page only

<% @ Page Language="C#" MasterPageFile="~/Master.master" Title="Content Page 1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" Runat="Server">
    //other scripts specific to this page only
    <script type="text/javascript" src="js/jquery.plugin.abc.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Main" Runat="Server">
    Main content.
</asp:Content>

o.k.w