Solved

Where do I put scriptmanager when using an ascx?

Posted on 2009-07-08
5
2,007 Views
Last Modified: 2012-06-21
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

0
Comment
Question by:Asfaloth
5 Comments
 
LVL 8

Accepted Solution

by:
Bob Hoffman earned 500 total points
ID: 24808534
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
 
LVL 20

Expert Comment

by:ddayx10
ID: 24810162
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
 
LVL 22

Expert Comment

by:prairiedog
ID: 24815456
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
 

Author Comment

by:Asfaloth
ID: 24816613
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
 

Author Comment

by:Asfaloth
ID: 24818043
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now