Reputation: 617
Just tried out VS2012 with the default template site and I'm totaly new to the concept how to include javascript and css. In the MasterPage the javascript seams to be included using the scriptmanager and scriptreference.
There are also some files like package.config.
Can someone explain how this is supposed to be used. How do I include my own javascript & css. How do I add a jquery ready() to the site.master?
Upvotes: 1
Views: 4980
Reputation: 6123
To inculde a css file to your site add a link tag in the <head>
section of your page, for javascript add a script tag.
<head>
<link href="file.css" type="text/css" /> // This wil include your css file
// For JavaScript
<script src="jquery.js" type="text/javascript" ></script> // This wil include your java script file
<script type="text/javascript" >
// write Your JavaScript code here
// For using jquery code, add jquery method inside the script tag, example below
$("document").ready( {
// your jquery code
});
</script>
</head>
Script manager is used for different purposes:
1) Using Ajax Controls
2) When we access web services in Client Side
3) Page Methods etc
From MSDN about ScriptManager:
You must use a ScriptManager control on a page to enable the following Microsoft Ajax features of ASP.NET:
Client-script functionality of the Microsoft Ajax Library, and any custom script that you want to send to the browser. For more information, see Creating Custom Client Script by Using the Microsoft Ajax Library.
Partial-page rendering, which enables regions on the page to be independently refreshed without a postback. The ASP.NET UpdatePanel, UpdateProgress, and Timer controls require a ScriptManager control in order to support partial-page rendering.
JavaScript proxy classes for Web services, which enable you to use client script to access Web services and specially marked methods in ASP.NET pages. It does this by exposing the Web services and page methods as strongly typed objects.
JavaScript classes to access ASP.NET authentication, profile, and roles application services.
Upvotes: 1