简体   繁体   English

在asp.net webforms中引用javascript文件

[英]Referencing javascript files in asp.net webforms

Apologies if this question is very trivial for most of you but i am a rookie trying to use HTML5 with asp.net web forms. 抱歉,如果这个问题对你们大多数人来说都是微不足道的,但我是一个尝试将HTML5与asp.net网络表单结合使用的新手。 Please don't ask why i am not using MVC4 or 5 as its a clients requirement. 请不要问我为什么不使用MVC4或5作为客户要求。 I don't understand why the page cannot find the referenced js files in my application. 我不明白为什么页面无法在我的应用程序中找到引用的js文件。

My JS Scripts are in the following location: WebFormsTest->Scripts->WebForms Here is the code 我的JS脚本位于以下位置:WebFormsTest-> Scripts-> WebForms这是代码

@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs"    Inherits="WebFormsTest.Login" %> 

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head runat="server">
    <title>Login</title>
    <script  src="/Scripts/WebForms/jquery-1.10.2.js"></script> 
    <script  src="/Scripts/WebForms/jquery-ui-1.10.2.js"></script>
  </head>
  <body>
     <form id="form1" runat="server">
  </body>
</html>

When i run the following code i get the error message in firebug console saying the referencing scripts cannot be found. 当我运行以下代码时,我在firebug控制台中收到错误消息,指出无法找到引用脚本。 Eventhough the src is pointing to the right address why can't it find the files? 虽然src指向正确的地址,为什么它找不到文件? Anybody got workaround for this? 有人为此解决了问题吗?

Thank you 谢谢

Try to use: 尝试使用:

<script src="Scripts/WebForms/jquery-1.10.2.js"></script> 
<script src="Scripts/WebForms/jquery-ui-1.10.2.js"></script>

or: 要么:

<script src="~/Scripts/WebForms/jquery-1.10.2.js"></script> 
<script src="~/Scripts/WebForms/jquery-1.10.2.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM