2014-01-30 73 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。 –

相關問題