I have below scenario in my ASP.net using C# application
Master page:
I have included below code in Site.Master to register the scriptmanager as used some Telerik controls in it:
<%# Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="true">
<Scripts>
<asp:ScriptReference Path="~/Scripts/jquery-1.8.2.min.js" />
<asp:ScriptReference Path="~/Scripts/knockout-2.1.0.js" />
<asp:ScriptReference Path="~/Scripts/app.js?v=1" />
</Scripts>
</telerik:RadScriptManager>
I have a Data.aspx page on which I have a button which opens up a popup which is ShowPopup.aspx
In ShowPopup.aspx I have used Telerik RadGrid and also a UpdatePanel so included below scriptmanager code:
<asp:ScriptManager ID='scriptManager' runat='server' EnablePageMethods="true" />
I haven't included any scriptmanager code on Data.aspx page.
I have another ascx page which is used to set header of every panel. Below is the code we have used for Header.ascx page:
<asp:UpdatePanel ID="ContentHeaderUpdatePanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<div class="contentHeader">
<div runat="server" id="PageHeader">Content Title</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
And I haven't included any ScriptManager in this ascx file
We have using this header page in ShhowPopup.aspx page like:
<uc:ContentHeader ID="Header" runat="server" Title="Employee Details" />
Issue is, when I click on button in Data.aspx page, a popup (ShowPopup.aspx) page should open giving details, but instead it is giving Server Error in application like:
The control with ID 'ContentHeaderUpdatePanel' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it
proper error description can be found
I tried to add ScriptManager control in Header.ascx page but then it gives Error like:
Only one instance of scriptmanager can be added to the page
I can also see error when I try to see design view of ShowPopup.aspx page:
Error Creating Control - EmployeeGrid Failed to create designer 'Telerik.Web.UI.RadGrid, Telerik.Web.UI, Version=2013.1.417.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4'
One more issue is there.
I have IIS setup at my laptop and also deployed code on server. Error can not be reproduced on the one where IIS is setup. Why is it so?
Related
I need to display popup when page loads. I have used ModelPopupExtender. It does shows on it's TargetControlID click but not showing on page load from code behind.
I have check many solutions on stack but none of them are working for me.
protected void Page_Load(object sender, System.EventArgs e)
{
this.mpOTP.Show();
}
<asp:Button ID="activateMpOtp" runat="server" Text="Open" ClientIDMode="Static"/>
<asp:ModalPopupExtender ID="mpOTP" runat="server" BackgroundCssClass="popup-overlay" PopupControlID="pnlOTP" CancelControlID="closeOTP" TargetControlID="activateMpOtp"></asp:ModalPopupExtender>
<asp:Panel ID="pnlOTP" runat="server" CssClass="popup-dialogue">
</asp:Panel>
Getting this error in console
Your markup is not correct.
First of all, you need to register AjaxControlToolKit controls by using the following directive at the top of your page markup, just after the page directive.
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act %>
Then, your markup should look like the following. Problems with your markup are listed below.
You have not included markup for the cancel button
and also your control prefix is wrong since it should not be asp which is the prefix is for ASP.Net Microsoft controls and not for AJAXControlToolKit (NOTE: you give this prefix in your register directive for AjaxControl,Toolkit, which is act in code sample given, but you could give any prefix and use it for modalpopuextender)
Correct markup for ModalPopupExtender
<asp:Button ID="activateMpOtp" runat="server" Text="Open" ClientIDMode="Static"/>
<act:ModalPopupExtender ID="mpOTP" runat="server" BackgroundCssClass="popup-overlay"
PopupControlID="pnlOTP" CancelControlID="closeOTP"
TargetControlID="activateMpOtp"></act:ModalPopupExtender>
<asp:Panel ID="pnlOTP" runat="server" CssClass="popup-dialogue">
<div class="header">
Modal Popup
</div>
<div class="body">
Your content goes here
<br />
<asp:Button ID="closeOTP" runat="server" Text="Close" />
</div>
</asp:Panel>
I am using HtmlEditorExtendor in my project but it says :
HtmlEditorExtender is not a know element .
I've Tried : Link 1
But nothing seems to work for me .
I've added all references but still it's not working .
Here is my code :
Assemble after page directive before the asp:Content :
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
Here is the code for script manager and htmlEditorExtendor :
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:TextBox ID="txt_description" runat="server" Width="100%" Height="250" />
<asp:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" TargetControlID="txt_description" EnableSanitization="false">
</asp:HtmlEditorExtender>
The same page has asp:UpdatePanel which is working fine but asp:HtmlEditorExtender is not working .
Kindly help.Thanks
It has been removed since version 15.1. You can just use the normal ScriptManager.
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
Source
When I am trying to create a calendar control in asp.net using ajax it throws me an error
Unknown server tag 'cci:CalendarExtender'
The code is:
<%# Register Assembly ="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cci" %>
<asp:TextBox ID="date1" runat="server" ></asp:TextBox>
<asp:ImageButton runat="server" ID="img1" ImageUrl="~/images/calendar.png"/>
<cci:CalendarExtender runat="server" ID="cal1" PopupbuttonID="img1" TargetControlID="date1" Format="dd/mm/yyyy"></cci:CalendarExtender>
How to solve this issue?
I suspect you are not using script Manager on your Page.
Don't forget to add the script manager - though I don't think that would account for the error
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
I have been dealing with an unusual set of errors when I try to compile my asp.net page. This page is inheriting from my masterpage. It should be getting the Scriptmanager from there. But the errors I am getting suggest that it is not.
Now I have this in my page:
<%# Page Title="MassUpdate" Language="C#"
MasterPageFile="~/Site1.Master"
AutoEventWireup="true"
CodeBehind="Update.aspx.cs"
Inherits="AdminSite.Update"
MaintainScrollPositionOnPostback="true" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server" >
<div id="contentarea">
<div>
<h3 style="color:Red; padding-left:5px;">
WARNING - This page can push large amounts of data into the database. Use care when using it!
</h3>
</div>
<asp:ScriptManagerProxy runat="server" >
</asp:ScriptManagerProxy>
And in my masterpage, I have this:
<body>
<header>
<div id="banner">
<h1 style="color:#DBFFFF">UAC Parts Admin</h1>
</div>
</header>
<form id="form1" runat="server">
<div id="container">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
<asp:LoginView ID="LoginView1" runat="server" EnableViewState="false">
<LoggedInTemplate>
<div id="menubar">
<h6>Reports</h6>
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/Scripts/jquery.js" />
<asp:ScriptReference Path="~/Scripts/jqueryui.js" />
<asp:ScriptReference Path="~/Scripts/menubar.js" />
</Scripts>
</asp:ScriptManager>
The first error is this:
The control with ID '' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.
It happens when I don't have ScriptManager on my page and use ScriptManagerProxy instead.Even though I have ScriptManager on my Master page.
Now when I put a ScriptManager on my page I get a different error.
Only one instance of a ScriptManager can be added to the page.
What do I need to do to get this to work?
Is this an issue with one of my Nuget Packages? (JuiceUI,Widgmo, etc)
I would be glad to post code if requested.
EDIT:
Yeah, this whole thing has been weird. Oddly the master page did not have issues itself. But only when the other pages used it did I have any problems. Moving it to the first element after the form tag was the solution I believe. Though I had also moved the ScriptManagerProxy up a bit in my code too.
The ScriptManager must appear before any ContentPlaceHolders. Generally as Joshua pointed out, the script manager is put at the first element after the form tag. Like so:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/Scripts/jquery.js" />
<asp:ScriptReference Path="~/Scripts/jqueryui.js" />
<asp:ScriptReference Path="~/Scripts/menubar.js" />
</Scripts>
</asp:ScriptManager>
<div id="container">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
The reason for this is because the .aspx pages that uses this master page provide content that is placed into the ContentPlaceHolder controls. Because your ContentPlaceHolder appeared before your ScriptManager, the ScriptManagerProxy located in your content page was throwing because the ScriptManager would not be defined until later down the page.
This can be a bit odd to think about because you are defining controls in multiple different places. But the codebehind does not execute until everything is put together.
Put the ScriptManager on masterpage and ScriptManagerProxy on the .aspx page.
you need to put the script manager near your form declaration in Master page;
have a look on this Also: Walkthrough: Creating an Ajax-Enabled Web Site
<body>
<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
...
</form>
</body>
For Your Second Question:ScriptManager Control Overview
Only one instance of the ScriptManager control can be added to the page.
The page can include the control directly, or indirectly inside a nested
component such as a user control, content page for a master page, or nested
master page. If a page already contains a ScriptManager control, but a nested
or parent component needs additional features of the ScriptManager control, the
component can include a ScriptManagerProxy control.
For example, the ScriptManagerProxy control enables you to add scripts and
services that are specific to nested components.
you either have to remove your script manager from master page if wanted to use in Content page or Use proxy in content page with in-addition of script manager in master page
I've got an issue with a messagebox user control. I wish for a control which can be given a message and the user can dismiss with a click of a button, which can be inserted into many places.
I have applied the javascript into the messagebox control in a hope i can keep everything to do with the messagebox centralized, however when browsing to a page with the messagebox control added i get this error:
CS1061: 'ASP.components_messagebox_ascx' does not contain a definition for 'HideBox' and no extension method 'HideBox' accepting a first argument of type 'ASP.components_messagebox_ascx' could be found
The control is as thus:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="Messagebox.ascx.cs" Inherits="FosterNetwork.Components.Messagebox" %>
<script type="text/Javascript">
function HideBox() {
document.getElementById("PNL_Messagebox").setAttribute("visible", false);
}
</script>
<asp:Panel ID="PNL_Messagebox" runat="server">
<asp:Label ID="LBL_Message" runat="server" />
<asp:Button ID="BTN_Ok" Text="Ok" OnClick="HideBox()" runat="server" /> <!--Error happens on this line-->
</asp:Panel>
I'm fairly certain i've done this right but obviously i've done something wrong if it's not working. Any light on the situation at all would be grand.
Addendum: If i comment out the Button control the page loads fine, and the script loads fine too (Viewed page source)
The control ID's you're referencing are not the client ID's, but server ID's. So retrieve the 'ClientID' from the control in the JavaScript function and second, use the 'OnClientClick' property to show the JavaScript message.
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="Messagebox.ascx.cs" Inherits="FosterNetwork.Components.Messagebox" %>
<script type="text/Javascript">
function HideBox() {
document.getElementById("<%= PNL_Messagebox.ClientID %>").setAttribute("visible", false);
}
</script>
<asp:Panel ID="PNL_Messagebox" runat="server">
<asp:Label ID="LBL_Message" runat="server" />
<asp:Button ID="BTN_Ok" Text="Ok" OnClientClick="HideBox()" runat="server" /> <!--Error happens on this line-->
</asp:Panel>
Onclick looks for a server side function, and not javascript. either, define your button as <input type='button' onclick='HideBox' or change the current code to:
<script type="text/Javascript">
function HideBox() {
document.getElementById("<%= PNL_Messagebox.ClientID %>").setAttribute("visible", false);
return false;
}
</script>
<asp:Button ID="BTN_Ok" Text="Ok" OnClientClick="return HideBox()" runat="server" />
returning false in OnClientClick, prevents the asp button from postback.
Edit: as Monty mentioned, your panel control's client id is not correctly set in your code.