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.



*** 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">
		&nbsp;
		<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">
           &nbsp;
           <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">
                                                    &nbsp;<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">
                                                    &nbsp;<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">
                                                    &nbsp;<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>

Open in new window

AsfalothAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob HoffmanDeveloperCommented:
Script manager would go in Editjob.aspx, UpdatePanels would go in the .ascx files.
Drop the script manager of the page from the design view that way you'll get all the proper directives.
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ddayx10Commented:
Alternately should work with ScriptManager on MasterPage and ScriptManagerProxy on .aspx page....this would be the way to go if you had some AJAX components on masterpage, also some on .aspx page, and then again more on .ascx page...

You may not have that scenario, but it's worth mentioning.
0
prairiedogCommented:
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
0
AsfalothAuthor Commented:
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.

0
AsfalothAuthor Commented:
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!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.