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?
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>
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>
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.
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.
The ScriptManager is a web control that you register in the page using
<asp:ScriptManager ID="ScriptManger1" runat="Server" />
inside the Form tag
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.
We need to add ScriptManager while using any AJAX Control not only update Panel.
<asp:ScriptManager ID="ScriptManger1" runat="Server" />
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.
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.
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.
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>
On the ASP.NET page, inside the form tags.
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" />
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>
<asp:ScriptManager ID="scriptManager1" runat="server">
</asp:ScriptManager>
Add above code after tag.
It worked for me.
Related
Telerik RadDatePicker inside ASP.NET UpdatePanel in Microsoft Edge browser throws JavaScript error when doing a post-back.
The error: "Unable to get property 'length' of undefined or null reference".
The RadDatePicker must be inside an UpdatePanel for the error to be thrown, and this ONLY happens in Microsoft Edge browser, all other browsers have no error.
Microsoft Edge version: 44.17763.1.0
Telerik Controls: Telerik.Web.UI, Version=2019.1.409.45
Any ideas how to fix this, or a work-around?
Here is my code:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EdgeDatePickerIssue.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Default</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager" runat="server" ScriptMode="Release" />
<asp:UpdatePanel runat="server" ID="upPanel">
<ContentTemplate>
<label>Select Date:</label>
<telerik:RadDatePicker ID="dpStartDate" runat="server"
AutoPostBack="true"
OnSelectedDateChanged="dpStartDate_SelectedDateChanged" />
<telerik:RadButton ID="btnSave" runat="server"
Text="Save" OnClick="btnSave_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Here is a screen-shot of the error:
Screen-shot Error in Edge
The problem is fixed in R2 2019.
Another way to solve it is setting the RadDatePicker's RenderMode property to Lightweight.
You could try to use Telerik RadScriptManager and Telerik RadAjaxPanel instead of using asp.net ScriptManager and UpdatePanel. Then, refer to this article to use DatePicker control.
I have a ASP.NET application with one Master Page and Multiple content pages.
This is a start of Master Page
<body>
<form runat="server">
<asp:ScriptManager runat="server">
<Scripts>
<%-- Scripts Omitted --%>
</Scripts>
</asp:ScriptManager>
.
.
.
.
.
Now, i have a Registration page with a form to submit. Here is the start
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<br />
<form id="Form1" runat="server">
<div class="register">
<br />
.
.
.
Whenever I tried to run the Register.aspx page, it gives me error as : A page can have only one server-side Form tag. and I know its because I have a Form tag on Master Page. Now if I tried to remove the form tag from Master Page (Which I thought unnecessary), I got error as : Control 'ctl01' of type 'ScriptManager' must be placed inside a form tag with runat=server.
My Question is : How can I use Form tag on Master as well as on content page without removing ScriptManager. Or is there any alternative to accomplish this ?
Just remove the form tag from your content pages - the form tag on the master page will be sufficient. You will need the ContentPlaceHolder tags on the master page to be within the form for this to work.
I've been reading SO for a while now, but that's the first time I post a question (first time I don't find the answer of what I'm looking for)
Here is my setup:
Master page:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Master.master.cs" Inherits="VatechWebsite.Master" %>
<html>
<head>...</head>
<body>
<form>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
...
<asp:ContentPlaceHolder ID="content" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
</html>
Content page:
<%# Page Title="" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="Brand.aspx.cs" Inherits="VatechWebsite.Brand1" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
<asp:Accordion ID="CategoriesAccordion" runat="server" HeaderCssClass="AccordionHeader">
<HeaderTemplate><%# DataBinder.Eval(Container.DataItem, "CategoryName") %></HeaderTemplate>
<ContentTemplate>
<div id="ProductList">Some text<br />supposed to be very large <br/></div>
</ContentTemplate>
</asp:Accordion>
<asp:Content/>
When I run this page, the accordion displays correctly, binds data correctly, and has the first pane expanded. The problem is, I cannot expand/collapse a pane. It seems that the javascript associated with this control is not running correctly. If I replace ScriptManager in the master page with a ToolkitScriptManager, the problem is solved; but I don't want to do that because I have other pages that need the ScriptManager.
I read that the ScriptManager should be adequate for running asp ajax controls, so why is it not working in this case?
If you're stuck with one ScriptManager for some pages, and ToolKitScriptManager for another, there are ways to use the same master page on all your pages, and use different ScriptManager on different pages.
This answer details a few approaches, one approach will disable Master.ShowScriptManager = false; on PageLoad.
Disable ScriptManager on certain pages
Another suggests having different ScriptManagers on for different ContentPlaceHolders, which also works.
Hope this helps!
I have a script manager in my code:
<asp:ScriptManager ID="masterScriptManager" runat="server" EnablePageMethods="True"
EnablePartialRendering="true" ScriptMode="Auto" AsyncPostBackTimeout="360">
<Scripts>
<asp:ScriptReference Path="~/scripts/web_resource.ashx?type=1&v=<%=version %>" />
</Scripts>
</asp:ScriptManager>
And I would like to add version info at the end of Path in script reference. I tried also with <%# but I only see encoded characters but not version number. What should I change?
One solution could be just adding this script reference in control's or page's code-behind during some of control/page life-cycle events (i.e. Load).
I have a website that uses the ASP.NET Login Controls and Forms Authentication. I've placed the asp:LoginStatus control inside another Web User Control that manages the display of the Header portion of my site.
The issue I have is that the ReturnURL presented by the LoginStatus control references the path to the Header Control, not the page the user is currently on. This is probably due to the class hierarchy and that the Header Control (ascx) actually uses Server.Execute on an .aspx file to generate the HTML. This is a work around to avoid the issue of not being allowed to have more than one server-side form on a page.
So the actual class Hierarchy of the Page is as follows:
Default.aspx - Uses Page.Master
Page.Master includes <foo:Header>
(with a reference to "~/Controls/Components/Header.ascx")
Header.ascx simply includes an <asp:Literal>
on Page_Load performs a Server.Execute ("~/Controls/Pages/Header.aspx")
and writes the content out to the Literal
Header.aspx includes <asp:LoginStatus>
When the user clicks on the Login link they are correctly redirected to Login.aspx, however the ReturnURL displayed is (incorrectly - although I can understand why) "ReturnUrl=%2fControls%2fPages%2fHeader.aspx".
Once on the Login page I can quite happily handle the LoggedIn event to correctly redirect the user to the right place. What I would like to do is either:
1) Remove the ReturnURL from the query string altogether
2) Be able to control the ReturnURL when the LoginStatus Control is rendered.
I've done some Reflector-ing of the System.Web.UI.WebControls.LoginStatus and it appears that it is hard-coded to always use a ReturnURL, based on the following code:
private string NavigateUrl
{
get
{
if (!base.DesignMode)
{
return FormsAuthentication.GetLoginPage(null, true);
}
return "url";
}
}
It is always setting reuseReturnURL to true.
Possibly, my only choice is to roll my own LoginStatus control?
[EDIT: Originally for the sake of brevity, I omitted the following details]
Here is a really simple example of what I am trying to acheive:
Web Application Project has the following structure:
WebSite
- Controls
- Components
- Footer.ascx
- Header.ascx
- MasterPages
- Site.Master
- Default.aspx
- Login.aspx
The page markups are below if you're interested.
I've created the Web User Control for separation of concerns, however on the Login page to use the asp:Login controls they need to be nested in a (server-side) form. The asp:LoginStatus control also needs to be nested in a (server-side) form. As you can't have more than one server-side form on a page, this breaks.
Also, the answer is not just to suppress the LoginStatus control on the Login page. Imagine if I just wanted to add a little Search Control on the main page, which would also rely on a (server-side) form. Hence the reason for using a Server.Execute and generating a page from an ASPX. This "tricks" .NET into allowing multiple server-side forms on a page. (Don't ask me how... I don't know!)
Maybe my entire architecture design is wrong, but how to others have multiple Web User Controls on a page that require server-side forms? Or don't they?
Site.Master markup:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="WebSite.MasterPages.Site" %>
<%# Register TagPrefix="bs" TagName="Footer" Src="~/Controls/Components/Footer.ascx" %>
<%# Register TagPrefix="bs" TagName="Header" Src="~/Controls/Components/Header.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body id="Body" runat="server">
<div id="container">
<!-- start header -->
<bs:Header ID="Header" runat="server" />
<!-- end header -->
<div id="central">
<div id="main">
<asp:PlaceHolder ID="MainContentPlaceHolder" runat="server">
<!-- start main content -->
<div>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</div>
<!-- end main content -->
</asp:PlaceHolder>
</div>
</div>
<!-- start footer -->
<bs:Footer ID="Footer" runat="server" />
<!-- end footer -->
</div>
</body>
</html>
Default.aspx markup:
<%# Page MasterPageFile="~/MasterPages/Site.Master" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebSite._Default" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="MainContent">
Main Body Content <br />
<br />
</asp:Content>
Header.ascx markup:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="Header.ascx.cs" Inherits="WebSite.Controls.Components.Header" %>
<div id="header">
Header Content <br />
<div id="loginstatus">
<form id="Form1" runat="server">
<asp:LoginView ID="displayloginname" runat="server">
<AnonymousTemplate>
Register
</AnonymousTemplate>
<LoggedInTemplate>
Welcome
<asp:LoginName runat="server" ID="ctlLoginName" />
</LoggedInTemplate>
</asp:LoginView>
<asp:LoginStatus ID="displayloginstatus" runat="server" LoginText="Login" LogoutPageUrl="~/Default.aspx"
LogoutAction="Redirect" />
</form>
<br />
</div>
</div>
Footer.ascx markup:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="Footer.ascx.cs" Inherits="Website.Controls.Components.Footer" %>
<div id="footer">
Footer Content
<ul class="links">
<asp:PlaceHolder ID="ListItems" Runat="server">
<li><a runat="server" id="HomeLink" href="~/">Home</a></li>
<li><a runat="server" href="~/" ID="A1">About Us</a></li>
<li><a id="A2" runat="server" href="~/">Contact Us</a></li>
<li><a id="A3" runat="server" href="~/">Privacy Policy</a></li>
<li><a id="A4" runat="server" href="~/">Accessibility Policy</a></li>
<li><a id="A5" runat="server" href="~/">Legal Notices</a></li>
<li><a id="A6" runat="server" href="~/">Sitemap</a></li>
<li><a id="A7" runat="server" href="~/">RSS Feeds</a></li>
</asp:PlaceHolder>
</ul>
</div>
Login.aspx markup:
<%# Page MasterPageFile="~/MasterPages/Site.Master" Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Website.Login" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="MainContent">
Main Body Content <br />
<br />
<form id="form1" runat="server">
<div>
<asp:Login ID="Login1" runat="server">
</asp:Login>
</div>
</form>
</asp:Content>
I see two options:
Put your form tag in your master page. Just below the <div id="container"> and wrapping all content in that div.
Change your header to not require an ASP.NET form. Not sure if the LoginView or LoginStatus both require an ASP.NET form. And then you can leave the form tag for the aspx files that use the master page (like you have in Login.aspx). This is what I prefer is to only put form tags in aspx pages (not in master files) and make sure headers and footer do not need an ASP.NET form (they could use a regular form tag just not with runat=server).
Why do you do a Server.Execute of the Header.aspx from your Header.ascx? Why don't you just put the Header.aspx code in the Header.ascx. That way the ReturnUrl will be the page you expect it to be.
Something does not sound quite right here:
on Page_Load performs a Server.Execute("~/Controls/Pages/Header.aspx")
and writes the content out to the Literal
I am not understanding why you are doing this? You mention that it is because you are trying to get around the problem of ASP.NET not allowing more than one HtmlForm on a page. But if you are just putting the html contents from header.aspx into a literal then you are not using an HtmlForm?? So can you just put the contents of Header.aspx in a normal form tag (without runat=server)? Or can the login status control be put outside of the form entirely? Do the contents of Header.aspx really need a form in the first place?
I would take a good look at why you are writing the contents of your header.aspx page out to a literal and try and fix the problem there instead of diving into the LoginStatus control and changing it to do something it is not intended to do.
One other possible suggestion: If you really do need to do to load Header into a literal, can you use Page.LoadUserControl instead? This may automatically resolve the urls for you? Not 100% sure though.