[Problema] Cascading DropDown, funziona solo in locale?

martedì 18 novembre 2008 - 12.06

alberto_proasc Profilo | Newbie

Buongiorno a tutti, vi espongo il mio problema: sto cimentandomi con ASP.NET AJAX e sto riscontrando fastidiosi problemi con il controllo del suo toolkit "CascadingDropDown";
in pratica sviluppando la web application in locale mi funziona, mentre caricandola su un sito web mi carica (senza nessun errore)solo i 3 dropdown vuoti.
Vi posto il codice:

Pagina aspx:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb" Inherits="_Default3" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="sm1" EnablePageMethods="true" runat="server">
</asp:ScriptManager>
<table>
<tr>
<td>
Tipo
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" Width="341px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Modello
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" Width="341px">
</asp:DropDownList>
</td>
</tr>
</table>
</div>
<cc1:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="DropDownList1"
Category="Tipo" ServiceMethod="GetDropDownContents">
</cc1:CascadingDropDown>
<cc1:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="DropDownList2"
Category="Modello" ServiceMethod="GetTipoDaModello" ParentControlID="DropDownList1">
</cc1:CascadingDropDown>
</form>
</body>
</html>

Codice della pagina:

Imports System.Data
Imports AjaxControlToolkit
Imports System.Collections
Imports System.Collections.Generic
Imports System.Collections.Specialized

Partial Class _Default3
Inherits System.Web.UI.Page
Const ConstBronze As Integer = 2
Const ConstGold As Integer = 3

<System.Web.Services.WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
Public Shared Function GetDropDownContents(ByVal knownCategoryValues As String, ByVal category As String) As AjaxControlToolkit.CascadingDropDownNameValue()
Try
Dim myConnection As New Data.OleDb.OleDbConnection
'myConnection.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\Documents and Settings\..."
myConnection.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=D:\inetpub\webs\..."
myConnection.Open()
Dim strConfQuery As String = "SELECT * FROM modello"
Dim cmdFetchConf As Data.OleDb.OleDbCommand = New Data.OleDb.OleDbCommand(strConfQuery, myConnection)
Dim dtrConf As Data.OleDb.OleDbDataReader
Dim myConferences As New List(Of CascadingDropDownNameValue)
dtrConf = cmdFetchConf.ExecuteReader
While dtrConf.Read()
Dim strConfName As String = dtrConf("descrizione").ToString
Dim strConfId As String = dtrConf("ID").ToString
myConferences.Add(New CascadingDropDownNameValue(strConfName, strConfId))
End While
Return myConferences.ToArray
Catch ex As Exception
Dim myConferences As New List(Of CascadingDropDownNameValue)
myConferences.Add(New CascadingDropDownNameValue(ex.Message, ""))
Return myConferences.ToArray
End Try
End Function

<System.Web.Services.WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
Public Shared Function GetTipoDaModello(ByVal knownCategoryValues As String, ByVal category As String) As AjaxControlToolkit.CascadingDropDownNameValue()
Try
Dim myConnection As New Data.OleDb.OleDbConnection
Dim strConfQuery As String
Dim intConfId As Integer

Dim dtrTeam As Data.OleDb.OleDbDataReader
Dim kvTeam As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)

'leggo id del modello
If Not kvTeam.ContainsKey("CategoryValue") Or Not Int32.TryParse(kvTeam("Tipo"), intConfId) Then
Return Nothing
End If
'imposto query
If intConfId = ConstBronze Then
strConfQuery = "SELECT * FROM tipo WHERE bronze = TRUE"
ElseIf intConfId = ConstGold Then
strConfQuery = "SELECT * FROM tipo WHERE gold = TRUE"
Else
Return Nothing
End If

'apro connessione
'myConnection.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\Documents and Settings\..."
myConnection.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=D:\inetpub\webs\..."
myConnection.Open()
Dim cmdFetchTeam As Data.OleDb.OleDbCommand = New Data.OleDb.OleDbCommand(strConfQuery, myConnection)

cmdFetchTeam.Parameters.AddWithValue("@modello_id", intConfId)
Dim myTeams As New List(Of CascadingDropDownNameValue)
dtrTeam = cmdFetchTeam.ExecuteReader
While dtrTeam.Read()
Dim strTeamName As String = dtrTeam("descrizione").ToString
Dim strTeamId As String = dtrTeam("id").ToString
myTeams.Add(New CascadingDropDownNameValue(strTeamName, strTeamId))
End While
Return myTeams.ToArray
Catch ex As Exception
Dim myConferences As New List(Of CascadingDropDownNameValue)
myConferences.Add(New CascadingDropDownNameValue(ex.Message, ""))
Return myConferences.ToArray
End Try
End Function
End Class

Quindi, in locale, con la ConnectionString "Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\Documents and Settings\..." mi popola perfettamente tutte le liste a cascata, quando lo uppo in rete con l'altra che fa riferimento allo spazio web, le lascia completamente vuote, ma senza darmi errori.
Vi prego aiutatemi ringrazio anticipatamente!

Alberto
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5