JQuery的与母版页ASP.Net Web窗体 [英] JQuery in ASP.Net Web form with a master page

查看:202
本文介绍了JQuery的与母版页ASP.Net Web窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为CoursesPage.aspx页面,它有一个母版页。在CoursesPage.aspx我使用的课程名称自动完成的jQuery更好的搜索。这是我的脚本code:

I have a page named CoursesPage.aspx and it has a Master Page. In CoursesPage.aspx I'm using the autocomplete jquery on the course name for better searching. This is my script code:

<link rel="stylesheet" href="css/jquery-ui.css" />

    <script src="js/jquery-1.8.3.js" type="text/javascript" language="javascript"></script>

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

    <script type="text/javascript" language="javascript">
        function LoadList() {
            var ds = null;
            ds = <%=listFilter %>
        $("#txtName3").autocomplete({
            source: ds
        });
        }
    </script>

这code,如果我不使用母版页工作正常。但是,我不能把这个在CoursesPage.aspx标记的内容。它需要在头部标记,但我不能添加的内容标记。
请指引我。

This code works fine if I don't use the Master Page. However, I can't put this in the Content tag in the CoursesPage.aspx. It needs to be in the head tag but I can't add that in a content tag. Please guide me.

其次,这个函数被调用的body标签的负荷,但我也不能添加一个body标签。

Secondly, this function is called on the load of the body tag but I can't add a body tag either.

推荐答案

在你的母版页有两个标签的ContentPlaceHolder,一个在头和其他身体。
你必须在你的网页Courses.aspx添加两个内容的标签,并设置ContenetPlaceHolderID的属性之一,以母版页头的的ContentPlaceHolder。
例如:
您的母版页:

In your master page there are two ContentPlaceHolder tags, one in the head and the other in the body. You'll have to add two Content tags in your Courses.aspx page and set the one of the ContenetPlaceHolderID attributes to the master page head's ContentPlaceHolder. For example: Your master page:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="ResponsiveTemplate.Site" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<asp:ContentPlaceHolder ID="Head" runat="server">

</asp:ContentPlaceHolder>
</head>
<body>
<asp:ContentPlaceHolder ID="Content" runat="server">

</asp:ContentPlaceHolder>
</body>
</html>

和您的aspx页面:

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" CodeBehind="WebForm2.aspx.cs" Inherits="ResponsiveTemplate.WebForm2" %>

<asp:Content ID="content1" runat="server" ContentPlaceHolderID="Head">
<link rel="stylesheet" href="css/jquery-ui.css" />

<script src="js/jquery-1.8.3.js" type="text/javascript" language="javascript"></script>

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

<script type="text/javascript" language="javascript">
    function LoadList() {
        var ds = null;
        ds = <%=listFilter %>
    $("#txtName3").autocomplete({
        source: ds
    });
    }
</script>
</asp:Content>
<asp:Content ID="content2" runat="server" ContentPlaceHolderID="Content">
</asp:Content>

这篇关于JQuery的与母版页ASP.Net Web窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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