سؤال

How can I add the jQuery file for use in all pages of the web application?

I tried it this way and also using the ScriptManger as this in master page's Page_Load event:

ScriptManager manager = new ScriptManager();
manager.Scripts.Add(new ScriptReference("script/jquery-2.0.1.min.js"));
manager.Scripts.Add(new ScriptReference("script/jquery.contextMenu.js"));

but it does not work.

هل كانت مفيدة؟

المحلول

Do it declaratively in the master page by dragging the files from Solution Explorer window to the code view of the mark-up.

نصائح أخرى

Add your script to the master page head section, like:

<script src="<%=Page.ResolveClientUrl("~/scrpits/jquery1.7.js") %>" />

Just do it in the master page file.

When placing it in the master page, it applies to all pages that use the master page.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top