put All jquery Scripts in master page - asp.net

i am using jquery and jquery ui plugins in my web application.
and i have some asp.net server controls that they register their scripts on the page.
Since my application should be work Local could i put all scripts in master page ?
all scripts i mean jquery script and jquery Ui scripts such as DatePicker Dialog and effects.
or is there any better way exist?
because i want to jquery in all my pages and user Controls.
thanks.

Sticking them in the master is definitely the simplest approach if you intend to have them available on every page.
It sounds like you're including all the scripts individually though, you can include just one file for jQuery UI, for instance:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>

Yes, put them all in the Master Page.
Once they're downloaded, they'll be cached in the browser (if they already aren't)

Related

Render HTML (response of an aspx page) in Pega User Interface

I am migrating an aspx application in to Pega which has heavy UI pages.
When I tried to render the respective HTML in the form/ user interface tab of PRPC, most of the UI controls did not render and have to do heavy Pega coding to make it work.
Are there any best practices or tools available to optimize UI design by converting aspx pages UI elements in to Pega?
I can understand out-of-the-box customized controls cannot be rendered unless there is a converter.
No, how should that be possible? PRPC runs on a Java Application Server (Tomcat, Websphere or Weblogic) and thereby executes Java / JSP code - acting as a platform. The same way you can't just reuse php snippets in your Pega application.
In PRPC one UI rule type are sections. Sections are preferably auto generated, but you can choose to put in HTML code or even JSP code instead. There you could leverage the JavaScript frameworks included in PRPC or do includes on an iFrame basis. But you can't paste there php or aspx code since it won't be executed on the php resp. aspx environment.

Visual Studio 2012 javascript & css reference

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?
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.

MCTS70-515 question on ajax library?

You are implementing an ASP>NET application that makes extensive use of javscript libraries. Not all pages use all scripts, and some scripts depend on other scripts. When these libraries load sequentially, some of your pages load too slowly. You need to use the ASP>NET Ajax Library script Loader to load these scripts in parallel. Which two actions should you perform?(Each correct answer presents part of the solution. Choose two)
In your site's master page, add a call to Sys.loader.definescripts to define each of the scripts that are used in the site.
In your site's master page, add a call to Sys.loader.registerscript to define each of the scripts that are used in the site.
In each page that uses scripts, add a call to Sys.get for each script that is needed in that page.
In each page that uses scripts, add a call to Sys.require for each script that is needed in that page.
Please tell me which are the two answers are correct and why?
Thanks
1 and 4, because that's what http://weblogs.asp.net/bleroy/archive/2009/11/23/enabling-the-asp-net-ajax-script-loader-for-your-own-scripts.aspx and http://www.asp.net/ajaxlibrary/HOW%20TO%20Load%20Required%20Scripts.ashx imply.

404 Object Not Found for Javascript files

I have a .Net 1.1 webapp.
I have a usercontrol (.ascx) that has links to 3 JS files in
script tags.
When I run the app and load a page with the usercontrol
all is fine and Firebug shows the js files listed.
But when I load another page that loads the usercontrol in a .aspx
in a new browser window Firebug reports 404 object not found
for the 3 JS files.
What could cause this??
Malcolm
You other .aspx page is in a different folder? Possible at a different level in the folder hierarchy? You need to adjust you JS file paths so that they are absolute paths.
You probably have the other page in a different location in the folder hierarchy. Perhaps reference you JS with a server side tag with a ~ in it.
So try changing your JS path to something like this:
<script type="text/javascript" src='<%=ResolveUrl("~/someFolder/functions.js")%>'></script>
Use a tool like Microsoft Fiddler to help you understand the issue.
You could try using a basepath in you pages. In that case each url/image/css/js reference in your website will be relative to the basepath. Using a basepath in your site will prevent big issues when moving files into/from folders.
I usually place the base tag into the master page.
<base href="<%=MyWebsite.Library.Configuration.BasePath%>" />
As you can see the basepath is requested from my configuration, but you can also use .NET code to dertermine the basepath.
Using this constructions saves me a lot of issues when developing my pages. Only problem is that Visual Studio does not completely known how to handle this which causes some warnings about incorrect CssClasses or links.

how to cache a control, js files and css files in .net?

I have a master page, inside that I have a menu controls and other css, JS files.
Whenever I refresh the page from client, everything is coming from the server.
Now I want to cache those controls and those files as per session.
Is there any setting or programmatic settings there to do it?
You should read up on ASP.Net Caching - there are lots of flexible ways to cache your pages.
However in your case, it sounds like you should just be able to add the OutputCache directive to the top of your page:
<%# OutputCache Duration="60" VaryByParam="None"%>
Static CSS and JS files should be cached automatically by the browser. If you've embedded them as webresources then the caching directives will help you cache them as well.
There's no problem with JS and other items cached on client.
But yes, there's a concern on dynamic controls as they are not simply compiled and depend on request. And here's an article in Smöråkning blog on how to cache them.

Resources