2014-01-30 235 views
4

我一直在使用Visual Studio和Nuget的Ajax Control Toolkit V712213。但是当我尝试使用ModalPopupExtender时,它根本没有做任何事情。我曾在Stackoverflow,Codeproject以及其他知名网站上做了很多冲浪,但他们的建议都不适用于我的代码。Ajax控件工具包ModalPopupExtender无法在Visual Studio 2012中工作

我也从搜索中发现,许多正在使用Visual Studio 2012的最新AjaxControlToolkit的用户都面临这个问题。

这里是母版页

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="Attendance1.Site1" %> 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> 
<!DOCTYPE html> 

<html lang="en"> 
<head id="Head1" runat="server"> 
    <meta charset="utf-8" /> 
    <title><%: Page.Title %> - My ASP.NET Application</title> 
    <asp:PlaceHolder ID="PlaceHolder1" runat="server">  
      <%: Scripts.Render("~/bundles/modernizr") %> 
    </asp:PlaceHolder> 
    <webopt:BundleReference ID="BundleReference1" runat="server" Path="~/Content/css" /> 
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /> 
    <meta name="viewport" content="width=device-width" /> 
    <asp:ContentPlaceHolder runat="server" ID="HeadContent" /> 
</head> 
<body> 
    <form id="Form1" runat="server"> 

    <header> 
     <div class="content-wrapper"> 
      <div class="float-left"> 
       <p class="site-title"> 
        <img src="Images/logo.png" /> 
       </p> 
      </div> 
      <div class="float-right"> 
       <section id="login"> 
        <asp:LoginView ID="LoginView1" runat="server" ViewStateMode="Disabled"> 
         <AnonymousTemplate> 
          <ul> 


          </ul> 
         </AnonymousTemplate> 
         <LoggedInTemplate> 
          <p> 
           Hello, <a id="A1" runat="server" class="username" href="~/Account/Manage" title="Manage your account"> 
            <asp:LoginName ID="LoginName1" runat="server" CssClass="username" /></a>! 
           <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" /> 
          </p> 
         </LoggedInTemplate> 
        </asp:LoginView> 
       </section> 
       <nav> 
        <ul id="menu"> 


        </ul> 
       </nav> 
      </div> 
     </div> 
    </header> 
    <div id="body"> 
     <asp:ContentPlaceHolder runat="server" ID="FeaturedContent" /> 
     <section class="content-wrapper main-content clear-fix"> 

      <asp:ScriptManager ID="ScriptManager1" runat="server"> 
     <Scripts> 

      <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=272931&clcid=0x409 --%> 
      <%--Framework Scripts--%> 

      <asp:ScriptReference Name="MsAjaxBundle" /> 
      <asp:ScriptReference Name="jquery" /> 
      <asp:ScriptReference Name="jquery.ui.combined" /> 
      <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> 
      <asp:ContentPlaceHolder runat="server" ID="MainContent" /> 
     </section> 
    </div> 
    <footer> 
     <div class="content-wrapper"> 
      <div class="float-left"> 
       <p>&copy; <%: DateTime.Now.Year %> - My ASP.NET Application</p> 
      </div> 
     </div> 
    </footer> 
    </form> 
</body> 
</html> 

这是我的内容页提前

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site1.Master" CodeBehind="Login.aspx.cs" Inherits="abc" %> 

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> 

      <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
       <ContentTemplate> 
       <asp:panel ID="Panel1" style="display:none" runat ="server"> 
       <div class="HelloWorldPopup"> 
        <div class="PopupHeader" id="PopupHeader">Header</div> 
        <div class="PopupBody"> 
         <p>This is sample modal dialog</p> 
        </div> 
        <div class="Controls"> 
         <input id ="btnOk" type="button" value="Done" /> 
         <input id="btnCancel" type="button" value="Cancel" /> 
        </div> 
       </div> 
      </asp:panel> 
        <asp:Button ID="Button1" runat="server" Text="Click here to show the modal" /> 
        <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" DynamicServicePath="" PopupControlID="Panel1" Enabled="True" CancelControlID="btnCancel" TargetControlID="Button1"> 
        </ajaxToolkit:ModalPopupExtender> 
     </ContentTemplate> 
    </asp:UpdatePanel> 

</asp:Content> 

感谢

回答

3

你应该改变行:

<asp:ScriptManager ID="ScriptManager1" runat="server"> 

与此一个:

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnableScriptGlobalization="true"> 
+0

谢谢!我一直在试图弄清为什么它不能工作大约2个小时! – yrazlik

+0

在现代版本的Ajax工具包中,他们实际上摆脱了ToolkitScriptManager。我有同样的问题和愚蠢的,我从来没有检查控制台。原来我缺少使用新项目自动创建的Scripts \ WebForms \ MsAjax。 –

相关问题