Unknown server tag 'asp:ScriptManager' - asp.net

Line 115: <div>
Line 116: <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
Line 117: <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
Line 118: </asp:ContentPlaceHolder>
Line 119: <div style="width:100%; background-color:#2A5188; color:White;">
I have used this code in master page before asp updatepanel and get error unknown server tag ‘asp:scriptmanager’.

The tagprefix in your #register and the tag in front of the scriptmanager i.e. here asp must match.

Try to add
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</controls>
</pages>
It fixed an issue I had when running my app deployed on a specific Win Server 2016 box (running .NET 4.6.1).

Related

AJAX UpdatePanel fails to load in IIS 8.5 (Windows server 2012)

Problem Statement
When an event is fired, the updateprogress runs indefinitely and the update panel is not refreshed or the request does not end in IIS 8.5 (Windows Server 2012).
Code for reference below
MasterPage
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="XXXMaster.Master.cs" Inherits="XXXWeb.Common.MasterPage.CoReMQWebSite" %>
<asp:ScriptManager ID="ScriptManagerMain" runat="server" EnablePartialRendering="true" >
</asp:ScriptManager>
<asp:UpdateProgress ID="Updprg" runat="server">
<ProgressTemplate>
<div id="divProgress">
<table width="100%">
<tr>
<td>
<br />
</td>
</tr>
<tr>
<td align="center">
<asp:Label ID="lblProcessing" runat="server" CssClass="FieldLabel" Text="Processing... " />
</td>
</tr>
</table>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
}
function EndRequestHandler(sender, args) {
//debugger;
//if UpdatePanel error occurs...
if (args.get_error() != undefined) {
var Error = "Error Occurred: [Code]:" +
args.get_response().get_statusCode() + " [Message]: ";
alert(Error);
//Hide default ajax error popup
args.set_errorHandled(true);
//...redirect error to your Error Panel on page
//document.getElementById("Label1").innerText = Error;
}
}
</script>
aspx page
---------
<%# Page Language="C#" MasterPageFile="~/XXXMaster.Master" AutoEventWireup="true" ClientIDMode="AutoID" EnableEventValidation="false" CodeBehind="CommonAdminScreen.aspx.cs" Inherits="CoReMQWeb.CommonAdminScreen" Title="Common Admin Screen" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:UpdatePanel ID="upCommonAdmin" runat="server">
<ContentTemplate>
<asp:Button runat="server" ID="btnSaveCommonAdmin" CssClass="btn" onmouseout="this.className='btn'" onmouseover="this.className='btn btnhov'" Text="Save" CausesValidation="false" Width="75px" onclick="btnSaveCommonAdmin_Click" Visible="false"/>
<!-- then there is a grid to be updated on button click -->
Things already tried
Adding handlers in web.config
Web.config
<!--<add assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>-->
</assemblies>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
<authentication mode="Windows"/>
-->
<!--<authentication mode="Windows" />-->
<authentication mode="Forms">
<forms loginUrl="logon.ashx" name="AuthCookie" timeout="60" path="/"></forms>
</authentication>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
<trust level="Full" originUrl="" />
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<customErrors mode="Off" defaultRedirect="ErrorPageInternal.aspx" />
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<controls>
<!--<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>-->
<!--<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>-->
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx" />
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" />
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
The .Net framework is 4.5.2
In a mid of crisis, to make this workable before Friday. Any help/leads will be highly appreciated.
Thanks in advance.

Config Error: Section or group name 'system.web.extensions' is already defined

Afternoon All,
I have spent a good chunk of my time on the internet tryiong to solve the below issue but im getting myself a little confused. I am new to .net and im working in VS 2010.
Im trying to get a simple calendar to work with an image and a text box. I have the AjaxControlToolkit.dll (Version 3.5). I the following error when trying to get this calender to work:
Unable to cast object of type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection' to type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection'.
Here is my .aspx code (Which has a blue line right at the top of the page which states that there is a system.we.extensions error, but i already have this in my web config file?)
<%# Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></cc1:ToolkitScriptManager>
<div>
<asp:ImageButton runat="Server" ID="ImageButton1" ImageUrl="~/images/calendar.gif"
AlternateText="Click here to display calendar" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:calendarextender ID="CalendarExtender1" runat="server"
TargetControlID="TextBox1" PopupButtonID="ImageButton1">
</cc1:calendarextender>
</div>
</form>
</body>
</html>
And here is my web config file:
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings>
<add name="TestConn" connectionString="Data Source=Server1;Initial Catalog=CatalogName;User ID=UserID;Password=Password" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"></add>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"></add>
</assemblies>
</compilation>
<authentication mode="Windows"/>
<customErrors mode="Off"/>
<httpModules></httpModules>
<pages>
<controls>
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="cc1" />
<add tagPrefix="asp" namespace="System.Web.UI"
assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls"
assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
</system.web>
</configuration>
Many Thanks in advance.
Regards
Betty
You are adding the System.Web.Extensions section twice:
<add tagPrefix="asp" namespace="System.Web.UI"
assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls"
assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Remove one of them.
After you do that, you'll probably have some compilation errors. Just adjust the using statements to point to the appropriate namespace.

UpdatePanel - No errors, but web.config settings required?

I'm having issues getting UpdatePanel working in a large, existing solution. I have a sample page (below), which works in a freshly created demo website, but not when added to the existing target website.
The functionality is to isolate a dropdown's auto-postback, so I don't lose the contents of a FileUpload ASP control (it does this for security reasons, with some solutions described here)
In the target (non-demo) site, the control adds to the page fine (inc intellisense), and the page renders - but changing the drop down still performs a postback, rather than ajax-ifying the dropdown box.
The target solution mentioned was previously upgraded from ASP.NET v1.1, so I'm wondering if there's something I'm missing in the configuration?
The only difference I can find in the rendered HTML source is that the non-working version doesn't add the PageRequestManager, e.g.:
<script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ctl02', document.getElementById('form1'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tctl03'], [], [], 90);
//]]>
</script>
Sample page:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager2" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:DropDownList runat="server" ID="TestDropDown" AutoPostBack="true" OnSelectedIndexChanged="TestDropDown_SelectedIndexChanged">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
<asp:ListItem>Three</asp:ListItem>
</asp:DropDownList>
<asp:Literal runat="server" Text="Original state" ID="litText" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:FileUpload ID="FileUpload2" runat="server" />
</div>
</form>
</body>
</html>
And in the code behind:
protected void TestDropDown_SelectedIndexChanged(object sender, EventArgs e)
{
litText.Text = "Ajax update. The file details should still be present below";
}
I can confirm that the ScriptManager tag adds the following to the page source, so I assume the Ajax Toolkit has been added:
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
And that we have the following sections in web.config:
<compilation defaultLanguage="c#" debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
[...]
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, [...]
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions" [...]
[...]
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
The sample works in the demo site without the <Triggers> section, but I've tried adding it to the target site, to no avail.
Turns out the following should not be set in web.config, and occurs as a result of the upgrade from ASP.NET v1.1:
<xhtmlConformance mode="Legacy"/>
As discussed on ScottGu's blog post

Registering custom controls fails

I am attempting to register my user controls within the webconfig file because I am receiving the Element does not exist error, but I am receiving the following error when I try to register them in webconfig:
Invalid or missing attributes found in the tagPrefix entry. For user control, you must also specify 'tagName' and 'src'. For custom control, you must also specify 'namespace', and optionally 'assembly'
The following is the code within the webconfig file:
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="IPAMControl" tagName="contact_us" namespace="IPAM.Website.Controls" src="~/controls/contact_us.ascx" />
<add tagPrefix="IPAMControl" tagName="erh_list" namespace="IPAM.Website.Controls" src="~/controls/erh_list.ascx" />
<add tagPrefix="IPAMControl" tagName="header" namespace="IPAM.Website.Controls" src="~/controls/header.ascx" />
<add tagPrefix="IPAMControl" tagName="footer" namespace="IPAM.Website.Controls" src="~/controls/footer.ascx" />
<add tagPrefix="IPAMControl" tagName="main_tnavbar" namespace="IPAM.Website.Controls" src="~/controls/main_tnavbar.ascx" />
<add tagPrefix="IPAMControl" tagName="program_header" namespace="IPAM.Website.Controls" src="~/controls/program_header.ascx" />
<add tagPrefix="IPAMControl" tagName="program_list" namespace="IPAM.Website.Controls" src="~/controls/program_list.ascx" />
<add tagPrefix="IPAMControl" tagName="signup_section" namespace="IPAM.Website.Controls" src="~/controls/signup_section.ascx" />
<add tagPrefix="IPAMControl" tagName="speaker_list" namespace="IPAM.Website.Controls" src="~/controls/speaker_list.ascx" />
<add tagPrefix="IPAMControl" tagName="track" namespace="IPAM.Website.Controls" src="~/controls/track.ascx" />
</controls>
</pages>
The pages that are having this issue are also referencing MasterPages if that matters at all:
<%# Page Language="C#" AutoEventWireup="true" MasterPageFile="~/programs/MasterProgram.master" CodeBehind="~/programs/wim2011/default.aspx" Inherits="IPAM.Website.programs.wim2011._default" %>
and they are each within their own folders.
Please help.
Get rid of the namespace attribute, as it's confusing ASP.NET as to whether you're attempting to register a User Control or a Custom Control.
User Control:
<add tagPrefix="SomeTagPrefix" src="~/Controls/SomeControl.ascx" tagName="SomeTagName"/>
Custom Control:
<add tagPrefix="SomeTagPrefix" namespace="SomeNamespace" assembly="SomeAssembly"/>
So, in your example:
<add tagPrefix="IPAMControl" tagName="track" src="~/controls/track.ascx" />
And on the ASPX/ASCX, you use it like this:
<IPAMControl:track id="ipamTrack" runat="server" />
See here for more info.
EDIT
To prove this works - i did the following:
Create new Web Application
Create new folder called "Controls" in the root of the web application
Added a new "Web User Control" called "MyUserControl.ascx"
Modified web.config to add registration of control
Modified Default.aspx to add the control.
And it all works fine.
Here is the User Control:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="MyUserControl.ascx.cs" Inherits="WebApplication1.Controls.MyUserControl" %>
<span>Hi, im a user control, how are you?</span>
Here is the portion of the web.config i edited:
<pages>
<controls>
<add tagPrefix="MyControls" tagName="MyUserControl" src="~/Controls/MyUserControl.ascx"/>
</controls>
</pages>
Here is the Default.aspx change i made:
<MyControls:MyUserControl id="myUserControl" runat="server" />
And the page rendered correctly.
Now, unless what i have done here is different to how you have attempting to do it, you must have other code/errors that is interfering with this.
Don't know how much else help i can be.

Ajax Toolkit ASP.NET (Visual Basic) Not Displaying Calendar

I'm trying to use Ajax Toolkit in ASP.NET page to display a Calendar Extender with this code, but it's not working for me.
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<br />
<br />
<b>Calendar :</b><br />
<asp:TextBox ID="Date1" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="Date1">
</asp:CalendarExtender>
</div>
</form>
It's not displaying the calendar.
What's the problem ?
Try:
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="Date1">
</ajaxToolkit:CalendarExtender>
Update:
Do you have the following in your web.config?
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="asp" />
</controls>
</pages>
<compilation>
<assemblies>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx" />
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
Update II
Put the following at the top of your aspx page.
<%# Register Tagprefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
Also, you're referencing AjaxControlToolkit.dll, right? It should be in your bin directory. Right-click project, Add Reference menu choice to add.
Have you added a Register directive to your page for the CalendarExtender?
<%# Register TagPrefix="asp" TagName="CalendarExtender" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
(Or added it in web.config like Steve suggested)
Have you added an assembly reference to the AjaxControlToolkit dll?
Well it is caused by ScriptManager. I have this same issue. The solution is very simple just delete ScriptManager From page or where you placed i.e.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Once you delete scriptmanager then just place ToolkitscriptManager or below code:
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>
You can find this in toolbar -> ajax tab not in Ajax Extensions tab. I hope it will solve your issue

Resources