Solved

Where do I put scriptmanager when using an ascx?

Posted on 2009-07-08
5
2,047 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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