Wednesday, March 28, 2012

multiple ScriptManagers on a page

hi there; i've created the following page:

<%@dotnet.itags.org.PageLanguage="VB"MaintainScrollPositionOnPostback="true"AutoEventWireup="true"EnableEventValidation="false" %>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN"> <htmlxmlns="http://www.w3.org/1999/xhtml">

<headid="Head1"runat="server">

<title>Welcome</title>

<scriptlanguage="VB"runat="server">

ProtectedSub RedirectUser(ByVal senderAs System.Object,ByVal eAs System.EventArgs)

Dim tempID = ddlTemp.SelectedItem.Value

Response.Redirect("default.aspx?tempID=" & tempID)

EndSub

</script>

</head>

<body>

<formid="frm"defaultfocus="txtTemp"runat="server">

<atlas:ScriptManagerID="ScriptManager1"runat="server"/>

<divclass="index"> <center>

<tablewidth="100%"height="100%"border="0"cellpadding="0"cellspacing="0">

<tr>

<td>

<divstyle="width:615px; text-align:left;">

<atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server">

<atlasToolkit:CascadingDropDownPropertiesLoadingText="Loading"Category="B"TargetControlID="ddlB"

ServiceMethod="GetB"ServicePath="WebService.asmx"PromptText="Please select"/>

<atlasToolkit:CascadingDropDownPropertiesCategory="A"TargetControlID="ddlA"

ParentControlID="ddlB"LoadingText="Loading"ServiceMethod="GetA"ServicePath="WebService.asmx"

PromptText="Please select"/>

</atlasToolkit:CascadingDropDown>

<asp:DropDownListID="ddlB"runat="server"/>

<asp:DropDownListID="ddlA"AutoPostBack="true"OnSelectedIndexChanged="RedirectUser"runat="server"/>

<divstyle="margin-top:25px;">

<asp:TextBoxID="txtTemp"runat="server"></asp:TextBox>

<asp:ButtonID="cmdFindTemp"CssClass="submit"UseSubmitBehavior="false"OnClientClick="this.disabled = true; this.value = 'Submitting...';"runat="server"PostBackUrl="default.aspx"Text="Go!"/>

<atlas:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server">

<atlas:AutoCompletePropertiesServicePath="WebService.asmx"ServiceMethod="GetTemp"TargetControlID="txtTemp"Enabled="true"MinimumPrefixLength="1"/></atlas:AutoCompleteExtender>

</div>

</div>

</td>

</tr>

</table>

</center>

</div>

</form> </body>

</html>

this page basically displays a couple of dropdown lists, a textbox and a submit button.

as you can see, i'm using the atlas control and the atlas toolkit control.

to make the controls function, i'm using the atlas:Scriptmanager.

using asp:scriptmanager (instead of an atlas:Scriptmanager) causes my page to crash with the following error message:

Extender controls require a ScriptManager to be present on the page.
Parameter name: scriptManager

what's worse is that if i try to add an ajaxToolkit control, such as:

<ajaxToolkit:TextBoxWatermarkExtenderID="TextBoxWatermarkExtender1"runat="server"TargetControlID="txtTemp"WatermarkText="Type Name Here"WatermarkCssClass="watermarked"></ajaxToolkit:TextBoxWatermarkExtender>

then i get the following error:

The control with ID 'TextBoxWatermarkExtender1' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

well, the atlas:ScriptManager is before it and, again, i still get an error if i try using the asp:ScriptManager.

my question is, how many different scriptmanager's are there and what can i use that cover's all controls (i.e. ajax, ajaxToolbarKit, atlasToolbarKit)

thanks all.

Hi Chubbs,

Your problem is caused by the confilict between Atlas(previous version of Asp.Net Ajax Extension) and Asp.Net Ajax Extension. Ajax ControlToolkit works depend on Asp.Net Ajax Extension 1.0. So why not convert your application from "Atals" to "Asp.Net AJAX RTM" since it is more powerful and stable. It is recommended to update your Asp.Net Ajax Extension and Ajax ControlToolkit to the latest version.

Here is the way: http://ajax.asp.net/documentation/Migration_Guide_CTP_to_RTM.aspx

By can download the lastest released version here:http://ajax.asp.net/downloads/default.aspx?tabid=47

Hope it helps.


hi, jonathan; thanks for the response.

well, it took me several hours to tweak and work out the ensuing glitches, but it finally paid off. much cleaner now.

anyway, for the benefit of those who have the same issue, i will post my final working code.

basically, i have 2 cascading dropdowns that each receive their data from a database.

DROPDOWN.ASPX

======================================

<%@.PageLanguage="VB"MaintainScrollPositionOnPostback="true"AutoEventWireup="true"EnableEventValidation="false" %>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headid="Head1"runat="server">

<title>Cascading Drop Down</title>

<scriptlanguage="VB"runat="server">

</script>

<linkhref="styles.css"rel="stylesheet"type="text/css"/>

</head>

<bodyclass="index">

<formid="frmIndex"defaultfocus="txtCompany"runat="server">

<asp:ScriptManagerID="ScriptManager1"runat="server"/>

<divid="index">

<center>

<tablewidth="100%"height="100%"border="0"cellpadding="0"cellspacing="0">

<tr>

<td>

<divstyle="width:630px; text-align:right;">

<ajaxToolkit:CascadingDropDown

LoadingText="Loading Provinces"

Category="Province"

ID="CascadingDropDown1"

TargetControlID="ddlProvince"

ServiceMethod="GetProvinces"

ServicePath="WebService.asmx"

PromptText="Please select a province"

runat="server"/>

<ajaxToolkit:CascadingDropDown

LoadingText="Loading Cities"

ParentControlID="ddlProvince"

Category="City"

ID="CascadingDropDown2"

TargetControlID="ddlCity"

ServiceMethod="GetCities"

ServicePath="WebService.asmx"

PromptText="Please select a city"

runat="server"/>

<asp:DropDownListID="ddlProvince"runat="server"/>

<asp:DropDownListID="ddlCity"AutoPostBack="true"OnSelectedIndexChanged="RedirectUser"runat="server"/>

</div>

</td></tr>

</table>

</center>

</div>

</form>

</body>

</html>

WEBSERVICE.VB

======================================

Imports System.Web

Imports System.Web.Services

Imports System.Web.Services.Protocols

Imports System.Collections.Generic

Imports AjaxControlToolkit

Imports System.Data

Imports System.Data.SqlClient

Imports System.Collections

Imports System.Collections.Specialized<WebService(Namespace:="http://tempuri.org")> _

<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

<System.Web.Script.Services.ScriptService()> _

PublicClass WebServiceInherits System.Web.Services.WebService

<WebMethod()> _

PublicFunction GetProvinces(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As AjaxControlToolkit.CascadingDropDownNameValue()

Dim valuesAsNew System.Collections.Generic.List(Of AjaxControlToolkit.CascadingDropDownNameValue)

Dim myDatasetAs DataSet

myDataset = HttpContext.Current.Cache("tblProvince")

If myDatasetIsNothingThen

Dim myConnectionAsNew SqlConnection(ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString)

Dim myCommandAsNew SqlCommand("SELECT * FROM tblProvince", myConnection)

Dim myAdapterAsNew SqlDataAdapter(myCommand)

myDataset =New DataSet

myAdapter.Fill(myDataset)

HttpContext.Current.Cache.Insert("tblProvince", myDataset)

Else

myDataset =CType(HttpContext.Current.Cache("tblProvince"), DataSet)

EndIf

ForEach rowAs DataRowIn myDataset.Tables(0).Rows

values.Add(New CascadingDropDownNameValue(row("fldProvince"), row("fldProvinceID")))

Next

Return values.ToArray

EndFunction

<WebMethod()> _

PublicFunction GetCities(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue()

Dim kvAs StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)

IfNot (kv.ContainsKey("Province"))Then

ReturnNothing

EndIf

Dim valuesAsNew System.Collections.Generic.List(Of AjaxControlToolkit.CascadingDropDownNameValue)

Dim myConnectionAsNew SqlConnection(ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString)

Dim strSQLAsString ="SELECT * FROM tblCity WHERE (tblCity.fldProvinceID='" & kv("Province") &"')"

Dim myCommandAsNew SqlCommand(strSQL, myConnection)

Dim myAdapterAsNew SqlDataAdapter(myCommand)

Dim myDatasetAsNew DataSet

myAdapter.Fill(myDataset)

ForEach rowAs DataRowIn myDataset.Tables(0).Rows

values.Add(New CascadingDropDownNameValue(row("fldCity"), row("fldCityID")))

Next

Return values.ToArrayEndFunction

EndClass

WEB.CONFIG

======================================

<?xmlversion="1.0"?>

<configuration>

<configSections>

<sectionGroupname="system.web.extensions"type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

<sectionGroupname="scripting"type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

<sectionname="scriptResourceHandler"type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication"/>

<sectionGroupname="webServices"type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

<sectionname="jsonSerialization"type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="Everywhere" />

<sectionname="profileService"type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication" />

<sectionname="authenticationService"type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication" />

</sectionGroup>

</sectionGroup>

</sectionGroup>

</configSections>

<connectionStrings>

<addname="myConnectionString"connectionString="Data Source={SQLServer};Server=yourServer;Database=yourDatabase;Uid=yourID;Pwd=yourPassword;"/>

</connectionStrings>

<system.web>

<pages>

<controls>

<addnamespace="System.Web.UI"tagPrefix="asp"assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addnamespace="AjaxControlToolkit"assembly="AjaxControlToolkit"tagPrefix="ajaxToolkit"/>

<addnamespace="AtlasControlToolkit"assembly="AtlasControlToolkit"tagPrefix="atlasToolkit"/>

<addnamespace="System.Data"tagPrefix="asp"/>

<addnamespace="System.Data.SQLClient"tagPrefix="asp"/>

</controls></pages>

<compilationdebug="true">

<buildProviders>

<addextension=".asbx"type="Microsoft.Web.Services.BridgeBuildProvider"/>

</buildProviders>

<assemblies>

<addassembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addassembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

<addassembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<addassembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

</assemblies>

</compilation>

<httpHandlers>

<removeverb="*"path="*.asmx"/>

<addverb="*"path="*.asmx"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addverb="*"path="*_AppService.axd"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addverb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"validate="false"/></httpHandlers>

<customErrorsmode="Off"/>

<httpModules>

<addname="ScriptModule"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</httpModules>

</system.web>

<system.web.extensions>

<scripting>

<webServices>

<!-- Uncomment this line to customize maxJsonLength and add a custom converter-->

<!--

<jsonSerialization maxJsonLength="500">

<converters>

<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>

</converters>

</jsonSerialization>

-->

<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate.-->

<!--

<authenticationService enabled="true" requireSSL = "true|false"/>

--><!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved

and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and

writeAccessProperties attributes.-->

<!--

<profileService enabled="true"

readAccessProperties="propertyname1,propertyname2"

writeAccessProperties="propertyname1,propertyname2" />

-->

</webServices>

</scripting></system.web.extensions>

<system.webServer>

<validationvalidateIntegratedModeConfiguration="false"/>

<modules>

<addname="ScriptModule"preCondition="integratedMode"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</modules>

<handlers>

<removename="WebServiceHandlerFactory-ISAPI-2.0"/>

<addname="ScriptHandlerFactory"verb="*"path="*.asmx"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addname="ScriptHandlerFactoryAppServices"verb="*"path="*_AppService.axd"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addname="ScriptResource"preCondition="integratedMode"verb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

</handlers>

</system.webServer>

</configuration>

Well, there it is in it's entirety. Hopefully this will help someone get up and running with this control in the future.

Good luck!

No comments:

Post a Comment