The ScriptManager must appear before any controls that need it

前端 未结 10 1778
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 11:52

I have created a new ASP.NET Web Application, and after debugging i got Server Error

The control with ID \'WaitingPopup1\' requires a ScriptManager on

相关标签:
10条回答
  • 2020-11-28 12:38

    There many cases where script Manager may give problem like that. you Try This First add Script Manager in appropriate Placeholder or any place Holder which appears before the content in which Ajax Control is used.

    1. We need to add ScriptManager while using any AJAX Control not only update Panel. <asp:ScriptManager ID="ScriptManger1" runat="Server" />

    2. If you are using Latest Ajax Control Toolkit (I am not sure about version 4.0 or 4.5) you need to use that Particular ToolkitScriptManager and not ScriptManager from default Ajax Extensions.

    3. You can use only one ScriptManager or ToolKitScriptManager on page, If you have added it on Master Page you no need to add it again on Web Page.

    4. The problem mentioned here may because of ContentPlaceHolder Please Check how many content place holders you have on your master page. Lets take an example if you have 2 content Placeholders "Head" and "ContentPlaceHolder1" on Master Page and ContentPlaceHolder1 is your Content Page.please check below code I added here my ScriptManager on Second Placeholder just below there is update panel.

    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <asp:ContentPlaceHolder id="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ContentPlaceHolder id="MainContent" runat="server">
            <asp:ScriptManager ID="ScriptManger1" runat="Server" />
              <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        </ContentTemplate>
    </asp:UpdatePanel>
            </asp:ContentPlaceHolder>
        </div>
        </form>
    </body>
    </html> 
    

    Most of us make mistake while designing web form when we choose masterpage by default on web page there are equal number of placeholders as of MasterPage.

    <%@ Page Title="" Language="C#" MasterPageFile="~/Master Pages/Home.master" AutoEventWireup="true" CodeFile="frmCompanyLogin.aspx.cs" Inherits="Authentication_frmCompanyLogin" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    </asp:Content>
    

    We no need to remove any PlaceHolder it is guiding structure but you must have to add the web form Contents in Same PlaceHolder where you added your ScriptManager(on Master Page) or add Script Manager in appropriate Placeholder or any place Holder which appears before the content in which Ajax Control is used.

    0 讨论(0)
  • 2020-11-28 12:41

    Just put ScriptManager inside form tag like this:

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager> 
    

    If it has Master Page then Put this in the Master Page itself.

    0 讨论(0)
  • 2020-11-28 12:41

    The script manager must be put onto the page before it is used. This would be directly on the page itself, or alternatively, if you are using them, on the Master Page.

    The markup would be;

     <asp:ScriptManager ID="ScriptManager1" runat="server" LoadScriptsBeforeUI="true"
                EnablePartialRendering="true" />
    
    0 讨论(0)
  • 2020-11-28 12:42

    You can add your Script Manager tags just below the <Form> tag of your page. Here is how you can place your Script Manager tag.

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

    If you are using Master Pages, its recommended to use your Script Manager in your Master page so that you do not have to write it again and again on every page that contains AJAX controls.

    0 讨论(0)
提交回复
热议问题