• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2157
  • Last Modified:

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:
Editjob.aspx, contains three user controls
      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">
		<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">
		<form id="Form2" method="post" runat="server">
		<asp:ScriptManager ID="ScriptManager1" 
                               runat="server" />
*** Put scriptmaster in the form on the parent page, editjob.aspx.
		<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
                                                <td class="Form" style="width: 464px; height: 30px" valign="top">
                                                    &nbsp;<asp:DropDownList ID="ddlInsPCat" runat="server">
                                                    <cc1:CascadingDropDown ID="ccdInsPCat" 
                                                        PromptText="Select a Product Category"
                                                        LoadingText="Loading categories...">
                                                <td class="Form" style="width: 464px; height: 30px" valign="top">
                                                    &nbsp;<asp:DropDownList ID="ddlInsPFam" runat="server">
                                                    <cc1:CascadingDropDown ID="cddInsPFam"
                                                        PromptText="Select a Product Family"
                                                        LoadingText="Loading families..."
                                                <td class="Form" style="width: 464px; height: 30px" valign="top">
                                                    &nbsp;<asp:DropDownList ID="ddlInsPProd" runat="server">
                                                    <cc1:CascadingDropDown ID="ccdInsPProd"
                                                        PromptText="Select a Product"
                                                        LoadingText="Loading products..."

Open in new window

1 Solution
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.
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.
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.
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.

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">
                                    <table cellspacing="0" cellpadding="0" width="928" border="0" style="width: 928px;
                                        height: 884px">
                                           ***AJAX cascading drop downs here***
                                    <!--table 3 close-->

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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now