The ScriptManager must appear before any controls that need it

匿名 (未验证) 提交于 2019-12-03 02:08:02

问题:

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 the page. The ScriptManager must appear before any controls that need it.

I'm new with ASP.NET so where schould i install my ScriptManager, in the web.config?

回答1:

The ScriptManager is a control that needs to be added to the page you have created.

Take a look at this Sample AJAX Application.

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


回答2:

If you are using microsoft ajax on your page you need the script manager control added to your master page or the page that needs it. It Manages ASP.NET Ajax script libraries and script files, partial-page rendering, and client proxy class generation for Web and application services

<asp:ScriptManager ID="ScriptManger1" runat="Server"> </asp:ScriptManager> 

The full usage

<asp:ScriptManager     AllowCustomErrorsRedirect="True|False"     AsyncPostBackErrorMessage="string"     AsyncPostBackTimeout="integer"     AuthenticationService-Path="uri"     EnablePageMethods="True|False"     EnablePartialRendering="True|False"     EnableScriptGlobalization="True|False"     EnableScriptLocalization="True|False"     EnableTheming="True|False"     EnableViewState="True|False"     ID="string"     LoadScriptsBeforeUI="True|False"     OnAsyncPostBackError="AsyncPostBackError event handler"     OnDataBinding="DataBinding event handler"     OnDisposed="Disposed event handler"     OnInit="Init event handler"     OnLoad="Load event handler"     OnPreRender="PreRender event handler"     OnResolveScriptReference="ResolveScriptReference event handler"     OnUnload="Unload event handler"     ProfileService-LoadProperties="string"     ProfileService-Path="uri"     RoleService-LoadRoles="True|False"     RoleService-Path="uri"     runat="server"     ScriptMode="Auto|Inherit|Debug|Release"     ScriptPath="string"     SkinID="string"     SupportsPartialRendering="True|False"     Visible="True|False">         <AuthenticationService             Path="uri" />         <ProfileService             LoadProperties="string"             Path="uri" />         <RoleService             LoadRoles="True|False"             Path="uri" />         <Scripts>             <asp:ScriptReference                 Assembly="string"                 IgnoreScriptPath="True|False"                 Name="string"                 NotifyScriptLoaded="True|False"                 Path="string"                 ResourceUICultures="string"                 ScriptMode="Auto|Debug|Inherit|Release" />         </Scripts>         <Services>             <asp:ServiceReference                 InlineScript="True|False"                 Path="string" />         </Services> </asp:ScriptManager> 


回答3:

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.



回答4:

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.



回答5:

The ScriptManager is a web control that you register in the page using

<asp:ScriptManager ID="ScriptManger1" runat="Server" /> 

inside the Form tag



回答6:

It simply wants the ASP control on your ASPX page. I usually place mine right under the tag, or inside first Content area in the master's body (if your using a master page)

<body>     <form id="form1" runat="server">         <asp:ScriptManager ID="scriptManager" runat="server"></asp:ScriptManager>         <div>             [Content]         </div>     </form> </body> 


回答7:

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.



回答8:

On the ASP.NET page, inside the form tags.



回答9:

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" /> 


回答10:

  • with a head tag with runat="server"
  • inside a form tag with runat="server"
  • before the ContentPanels that contain controls that require it - typical controls with UpdatePanels:

<%=PageTitle%>

</form>  </body> 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!