首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用ajaxToolkit:ToolkitScriptManager和asp:ScriptManager

使用ajaxToolkit:ToolkitScriptManager和asp:ScriptManager
EN

Stack Overflow用户
提问于 2014-07-10 05:56:38
回答 1查看 1.8K关注 0票数 0

我正在尝试在我的content.aspx页面中使用ajaxToolkit:Cal宪兵扩展程序。问题是我的site.master页面中有一个asp:ScriptManager标记。如何利用ScriptManagerProxy替换content.aspx页面中的ajaxToolkit:ToolkitScriptManager。

*下面的代码是我的site.Master *

代码语言:javascript
复制
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="cms.master.cs" Inherits="ccib.cms" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title><%: Page.Title %>>

    <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/modernizr") %>
    </asp:PlaceHolder>
    <webopt:bundlereference runat="server" path="~/Content/css" />

</head>
<body>
    <form id="form1" runat="server">



        <asp:ScriptManager ID="ScriptManagerProxy1" runat="server">
            <Scripts>
                <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
                <%--Framework Scripts--%>
                <%--<asp:ScriptReference Name="MsAjaxBundle" />--%>
                <asp:ScriptReference Name="jquery" />
                <asp:ScriptReference Name="bootstrap" />
                <asp:ScriptReference Name="respond" />
                <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
                <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
                <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
                <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
                <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
                <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
                <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
                <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
                <asp:ScriptReference Name="WebFormsBundle" />
                <%--Site Scripts--%>
            </Scripts>

        </asp:ScriptManager>


        <div class="container">
            <div class="row">
                <nav class="navbar navbar-default" role="navigation">

                </nav>
            </div>
        </div>

            <div class="container">

                   <div class="row">

                        <div class="container body-content">
                            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

                            </asp:ContentPlaceHolder>
                          </div>
                    </div>


                    <div class="row">
                            <footer>
                                  <p> &copy; <%: DateTime.Now.Year %> </p>
                            </footer>
                    </div>
                </div>

    </form>
</body>
</html>

*下面的代码是我的content.aspx *

代码语言:javascript
复制
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Content.aspx.cs" Inherits="ccib.mycms.Content" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>

<asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>  

    <ajaxToolkit:CalendarExtender 
        ID="CalendarExtender2"
        TargetControlID="txtStartDate"   
        Format="dd/MM/yyyy" 
        runat="server">

    </ajaxToolkit:CalendarExtender>

</asp:Content>
EN

回答 1

Stack Overflow用户

发布于 2014-07-11 02:32:14

我确实为此找到了一份工作,尽管我不确定它是否理想。对于那些也有这个问题的人,如果我在ToolScriptManager之前启动了ScriptManagerProxy,那么我就可以通过添加第二个母版页来使其正常工作。第二个Site.Master只使用ScriptManagerProxy。问题似乎是,我无法在内容页面中使用ScriptManagerProxy来提供利用ToolScriptManager的AJAX控件。在我找到更好的方法之前这是可行的。下面是我的代码供其他人参考。

* Site-AJAX.Master *

代码语言:javascript
复制
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" ></ajaxToolkit:ToolkitScriptManager>

<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
    <Scripts>
        <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
        <%--Framework Scripts--%>
        <%--<asp:ScriptReference Name="MsAjaxBundle" />--%>
        <asp:ScriptReference Name="jquery" />
        <asp:ScriptReference Name="bootstrap" />
        <asp:ScriptReference Name="respond" />
        <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
        <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
        <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
        <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
        <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
        <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
        <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
        <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
        <asp:ScriptReference Name="WebFormsBundle" />
        <%--Site Scripts--%>
    </Scripts>

</asp:ScriptManagerProxy>

Site.Master (用于需要ToolScriptManager的内容页)

代码语言:javascript
复制
  <asp:ScriptManager ID="ScriptManagerProxy1" runat="server">
        <Scripts>
            <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
            <%--Framework Scripts--%>
            <%--<asp:ScriptReference Name="MsAjaxBundle" />--%>
            <asp:ScriptReference Name="jquery" />
            <asp:ScriptReference Name="bootstrap" />
            <asp:ScriptReference Name="respond" />
            <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
            <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
            <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
            <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
            <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
            <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
            <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
            <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
            <asp:ScriptReference Name="WebFormsBundle" />
            <%--Site Scripts--%>
        </Scripts>

    </asp:ScriptManager>

也不要忘记将工具包添加到web.config文件.中。

代码语言:javascript
复制
<configuration>
    <system.web>
      <pages>
          <controls>
            <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
          </controls>
      </pages>
    </system.web>
</configuration>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24669383

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档