将jQuery挂钩到Asp.Net [英] hooking up jQuery to Asp.Net

查看:73
本文介绍了将jQuery挂钩到Asp.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我很难尝试将jQuery连接到Asp.Net。



我只是想在Default.aspx上显示一个图像滑块(在其他页面上不需要jQuery)。任何人都可以看到为什么jQuery滑块根本不显示?



滑块代码本身运行良好 - 我把它作为一个HTML文档,所以我认为它与我的编码有关。



我也收到一条错误信息说附加脚本调试器来处理机器上的[464] iexplore.exe ...失败。调试器已经附加了。



这是.Master代码:



Hi all,

I'm going nuts trying to hook up jQuery to Asp.Net.

I just want to show an image slider on Default.aspx (don't need jQuery on other pages). Can anyone see why the jQuery slider doesn't show at all?

The slider code works well in itself - I have it as an html document, so I think it has to do with my coding.

I also get an error msg saying that "Attaching the script debugger to process [464] iexplore.exe on machine ... failed. A debugger is already attached.

Here's the .Master code:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Conference.master.cs" Inherits="SiteMaster" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
    <title></title>
    <link href="Styles/conference.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form runat="server">
    <div class="page">
        <br />
        <div class="header">
            <div class="title">
                <h1>
                    My ASP.NET Application
                </h1>
            </div>
        </div>
        <div class="main">
            <asp:ContentPlaceHolder ID="PH1" runat="server" />
        </div>
        <div class="clear">
        </div>
    </div>
    <div class="footer">
    </div>
    </form>
</body>
</html>





这是Default.aspx代码:





Here's the Default.aspx code:

<%@ Page Title="" Language="C#" MasterPageFile="~/Conference.master" AutoEventWireup="true"

    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <link href="Styles/bjqs.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="Scripts/bjqs-1.3.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PH1" runat="Server">
    <!--  Outer wrapper for presentation only, this can be anything you like -->
    <div id="banner-fade">
    test
        <!-- start Basic Jquery Slider -->
        <ul class="bjqs">
            <li>
                <img src="img/banner01.jpg" title="Automatically generated caption" alt="" /></li>
            <li>
                <img src="img/banner02.jpg" title="Automatically generated caption" alt="" /></li>
            <li>
                <img src="img/banner03.jpg" title="Automatically generated caption" alt="" /></li>
        </ul>
        <!-- end Basic jQuery Slider -->
    </div>
    <!-- End outer wrapper -->
</asp:Content>





非常感谢!



Pettrer



Many thanks!

Pettrer

推荐答案

在ASP中没有'挂钩'jquery这样的东西。净。 ASP.NET从您的aspx文件生成HTML。如果你有一个母版页,你应该像你一样链接到jquery文件。但是,您不应该使用相对路径。它们更难调试。把/放在他们的前面。然后你有jquery,只要加载文件。您可以使用chrome中的调试器来检查它。



这个滑块是否自动运行?这有点难看,我使用的大多数jquery库都需要显式代码才能运行它们。但是,这不是你正在努力的jquery,它是一个jquery添加库。 Chrome会告诉您页面中是否有任何javascript错误,请记住,一个js错误并且js会因整个页面而停止。
There is no such thing as 'hooking up' jquery in ASP.NET. ASP.NET generates HTML from your aspx files. If you have a master page, you should link to the jquery files, as you are doing. You should not use relative paths, though. They are harder to debug. Put a / at the front of them. Then you have jquery, so long as the files loaded. You can use the debugger in chrome to check that.

Does this slider work automagically ? That's a bit ugly, most jquery libraries I use, require explicit code to run them. But, it's not jquery you're struggling with, it's a jquery add on library. Chrome will tell you if there's any javascript errors in your page, remember, one js error and js stops for your entire page.


这篇关于将jQuery挂钩到Asp.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆