ASP.net MVC 和 jQueryUI 困境

发布于 2024-07-08 05:28:12 字数 1123 浏览 8 评论 0原文

我刚刚将一个项目移至 ASP.net MVC 框架的测试版,我遇到的唯一问题是 jQueryjQueryUI

事情是这样的:

Site.Master 中有以下脚本引用:

<script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui.js" type="text/javascript"></script>

使用这些脚本引用,我在其中一个视图上拥有的 accordian UI 可以完美地工作,除了一个问题:页面中不包含来自 ThemeRoller 的图像。 如果我注释掉 jQuery 引用,ThemeRoller 图像就在那里。 所有 css 都位于 Content 文件夹 中,所有脚本都位于 Scripts 文件夹 中。

我知道这是一个愚蠢的路径问题,但它让我抽搐。

我缺少什么?

更新

我尝试了第一个答案,但没有成功,请阅读评论以了解详细信息。 再次感谢观看的各位。

第二种方法也行不通。 我很困惑。

另一个更新

对脚本使用 Url.Content 标签确实可以让脚本正常运行。 使用样式表的常规标签可以将所有样式添加到页面上,除了所有与 ThemeRoller 相关的样式。

jquery-ui-themeroller.css 文件位于 Content 文件夹中,当我检查元素时,CSS 就存在。 我怀疑问题出在从该 css 文件到 themeroller 的图像文件夹的映射中,该文件夹也位于 Content 文件夹中。 此文件中的图像链接指定为:background: url(images/foo.gif)

此文件中的链接是否需要更改?

I just moved a project to the the beta release of ASP.net MVC framework and the only problem I am having is with jQuery and jQueryUI.

Here's the deal:

In Site.Master are the following script references:

<script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui.js" type="text/javascript"></script>

And using those, the accordian UI that I have on one of the views works perfectly, except for one problem: the images from ThemeRoller aren't included on the page. If I comment out the jQuery references, the ThemeRoller images are there. All of the css is in the Content folder and all of the scripts are in the Scripts folder.

I know this is a silly path problem, but it's making me twitch.

What am I missing?

Update

I tried the first answer to no avail, read the comment for details. Thanks again for those who are viewing.

The second approach is not working either. I'm baffled.

Another Update

Using the Url.Content tags for the scripts does indeed allow the scripts to run properly. Using a regular tag for the stylesheet gets all of the styles onto the page EXCEPT for all of those related to ThemeRoller.

The jquery-ui-themeroller.css file is in the Content folder and when I inspect an element, the css is present. I suspect the problem is in the mapping from this css file to the images folder for the themeroller, which is in the Content folder as well. Image links in this file as specified as: background: url(images/foo.gif)

Do the links in this file need to change?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

怎樣才叫好 2024-07-15 05:28:12

除非所有视图都处于同一级别,否则您需要使用

  • 绝对路径,例如 /Scripts/jquery-1.2.6.js
  • 或者更好的是,解析虚拟路径,例如 <%= Url.Content (“~/Scripts/jquery-1.2.6.js”) %>

Url.Content() http://jvance.com/media/2008/10 /18/UrlContent5.media

Unless all your views are at the same level, you'll need to either use

  • Use an absolute path such as /Scripts/jquery-1.2.6.js
  • Or even better, Resolve a virtual path such as <%= Url.Content("~/Scripts/jquery-1.2.6.js") %>

Url.Content() http://jvance.com/media/2008/10/18/UrlContent5.media

汹涌人海 2024-07-15 05:28:12

这有帮助吗?

http://forums.asp.net/p/1334947/2690469.aspx

造成不一致的原因是
很简单,虽然我承认不是
很容易弄清楚! 当你有一个
<链接> ,ASP.NET 将处理
<链接> 标记并检测 URL 以及
解决它们相对于
应用程序的根目录。 当你有一个
<脚本> 页面上的标签(没有
runat="server") 那么 ASP.NET 将
不用管它,因为它很简单
旧的 HTML。

使用 Url.Content() 是我的方法
会用来解决这个问题,因为它会
相对于应用程序根目录得到解析,
就像<链接>一样 标签。

does this help?

http://forums.asp.net/p/1334947/2690469.aspx

The reason for the inconstistency is
very simple, though I admit it's not
easy to figure out! When you have a
<link> tag inside a <head
runat="server">, ASP.NET will process
the <link> tag and detect URLs and
resolve them relative to the
application's root. When you have a
<script> tag on the page (without
runat="server") then ASP.NET will
leave it alone since it's just plain
old HTML.

Using Url.Content() is the approach I
would use to solve this since it'll
get resolved relative to the app root,
just like the <link> tag.

忆离笙 2024-07-15 05:28:12

您需要更改 jquery-ui-themeroller.css 中的链接以指向图像的当前位置。

例如,您需要更新 css 文件正在查找的图像的路径。

background: url(images/foo.gif)

从路径中删除“images/”,使其看起来像:

background: url(foo.gif)

因为您的 css 和图像都位于内容文件夹中。

You need to change the links in jquery-ui-themeroller.css to point to the current location of the images.

As in, you need to update the path of the images that the css file is looking for.

background: url(images/foo.gif)

Remove the 'images/' from your paths to make it look like:

background: url(foo.gif)

as both your css and images are in the content folder.

笨死的猪 2024-07-15 05:28:12
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.ClientScript.RegisterClientScriptInclude(this.GetType(),"JQuery", ResolveUrl("~/js/jquery.min.js"));
        Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "JQueryUI", ResolveUrl("~/js/jquery-ui.custom.min.js"));
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.ClientScript.RegisterClientScriptInclude(this.GetType(),"JQuery", ResolveUrl("~/js/jquery.min.js"));
        Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "JQueryUI", ResolveUrl("~/js/jquery-ui.custom.min.js"));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文