Asfaloth
asked on
Where do I put scriptmanager when using an ascx?
I have inherited a web application written by someone else. I want to use AJAX cascading drop downs one one of the pages. When I wrote it as a separate web app it worked fine. Now I need to figure out how to get it working in a user control on a parent page. The problem seems to be with scriptmanager.
This is an asp.net application, using vb, framework 2.5.
My files are:
Master.aspx
Editjob.aspx, contains three user controls
Editjob_job.ascx
Editjob_projects.ascx (this is where the cascading dropdowns are)
Here are the scenarios Ive tried and their results. (Just code snippets here because the actual files are massive.)
*** Put scriptmanager in master.aspx
Editjob.aspx loads with no error
Editjob_job.ascx loads with no error
When I click on the tab for editjob_projects.ascx, I get the following error:
Additional information: The control with ID 'ccdInsPCat' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.
*** Put scriptmaster in the form on the parent page, editjob.aspx.
When editjob.aspx loads I get the following error:
Microsoft JScript runtime error: 'Sys' is undefined
I'm pretty sure putting it on the ascx page is not the correct thing to do.
Any help is greatly appreciated.
This is an asp.net application, using vb, framework 2.5.
My files are:
Master.aspx
Editjob.aspx, contains three user controls
Editjob_job.ascx
Editjob_projects.ascx (this is where the cascading dropdowns are)
Here are the scenarios Ive tried and their results. (Just code snippets here because the actual files are massive.)
*** Put scriptmanager in master.aspx
Editjob.aspx loads with no error
Editjob_job.ascx loads with no error
When I click on the tab for editjob_projects.ascx, I get the following error:
Additional information: The control with ID 'ccdInsPCat' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.
*** Put scriptmaster in the form on the parent page, editjob.aspx.
When editjob.aspx loads I get the following error:
Microsoft JScript runtime error: 'Sys' is undefined
I'm pretty sure putting it on the ascx page is not the correct thing to do.
Any help is greatly appreciated.
*** Put scriptmanager in master.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Master.aspx.vb" Inherits="EditJobs2.Master" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>master</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form2" method="post" runat="server">
<asp:ScriptManager ID="ScriptManager1"
runat="server" />
</form>
</body>
</HTML>
******************************
*** Put scriptmaster in the form on the parent page, editjob.aspx.
<body>
<form id="Form1" method="post" runat="server">
<asp:scriptmanager ID="Scriptmanager2" runat="server"></asp:scriptmanager>
<table cellSpacing="0" cellPadding="0" width="775" border="0">
<tr> <!--Header for all sections-->
<td> (etc.)
******************************
*** here are the cascading drop downs in the ascx file
<tr>
<td class="Form" style="width: 464px; height: 30px" valign="top">
<asp:DropDownList ID="ddlInsPCat" runat="server">
</asp:DropDownList>
<cc1:CascadingDropDown ID="ccdInsPCat"
runat="server"
ServicePath="ProdsService.vb.asmx"
ServiceMethod="GetInsPCats"
TargetControlID="ddlInsPCat"
Category="PCat"
PromptText="Select a Product Category"
LoadingText="Loading categories...">
</cc1:CascadingDropDown>
</tr>
<tr>
<td class="Form" style="width: 464px; height: 30px" valign="top">
<asp:DropDownList ID="ddlInsPFam" runat="server">
</asp:DropDownList>
<cc1:CascadingDropDown ID="cddInsPFam"
runat="server"
ServicePath="ProdsService.vb.asmx"
ServiceMethod="GetPFamsForPCats"
TargetControlID="ddlInsPFam"
Category="PFam"
PromptText="Select a Product Family"
LoadingText="Loading families..."
ParentControlID="ddlInsPCat">
</cc1:CascadingDropDown>
</td>
</tr>
<tr>
<td class="Form" style="width: 464px; height: 30px" valign="top">
<asp:DropDownList ID="ddlInsPProd" runat="server">
</asp:DropDownList>
<cc1:CascadingDropDown ID="ccdInsPProd"
runat="server"
ServicePath="ProdsService.vb.asmx"
ServiceMethod="GetPProdsForPFams"
TargetControlID="ddlInsPProd"
Category="PProd"
PromptText="Select a Product"
LoadingText="Loading products..."
ParentControlID="ddlInsPFam">
</cc1:CascadingDropDown>
</td>
</tr>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
First thing you will need to do is to modify your web.config so that the regular ASP.NET can be converted to the AJAX enable ASP.NET application, then you can start from there.
http://www.asp.net/ajax/documentation/live/ConfiguringASPNETAJAX.aspx
http://www.asp.net/ajax/documentation/live/ConfiguringASPNETAJAX.aspx
ASKER
Thanks for the suggestions, everyone. I'm looking at the web.config first. Although I don't think that will fix my problem, I was missing a couple of those modifications.
Next I'll try UpdatePanels. I saw those mentioned while trying to find a solution, but didn't really know what they were for. I need to next an asp:Panel within the asp:UpdatePanel and hope this won't be a problem.
ddavx10, I don't have AJAX components on any other pages as of yet, but if I can get this working I'm sure I will.
Next I'll try UpdatePanels. I saw those mentioned while trying to find a solution, but didn't really know what they were for. I need to next an asp:Panel within the asp:UpdatePanel and hope this won't be a problem.
ddavx10, I don't have AJAX components on any other pages as of yet, but if I can get this working I'm sure I will.
ASKER
As feared, when I try to put asp:UpdatePanel in my ascx, I got many errors. I finally tracked down that I needed to add a content template. So my ascx section now looks like this:
<asp:UpdatePanel runat=server ID="ProductHierarchyUP">
<ContentTemplate>
<table cellspacing="0" cellpadding="0" width="928" border="0" style="width: 928px;
height: 884px">
***AJAX cascading drop downs here***
</table>
<!--table 3 close-->
</ContentTemplate>
</asp:UpdatePanel>
My page now loads!
I will close and give HBHoffman the points for answering the original question. Trying to change the web.config opened up a new can of worms, so if I am unable to resolve that I will open a new question for you, prairiedog.
Thanks!
<asp:UpdatePanel runat=server ID="ProductHierarchyUP">
<ContentTemplate>
<table cellspacing="0" cellpadding="0" width="928" border="0" style="width: 928px;
height: 884px">
***AJAX cascading drop downs here***
</table>
<!--table 3 close-->
</ContentTemplate>
</asp:UpdatePanel>
My page now loads!
I will close and give HBHoffman the points for answering the original question. Trying to change the web.config opened up a new can of worms, so if I am unable to resolve that I will open a new question for you, prairiedog.
Thanks!
You may not have that scenario, but it's worth mentioning.