sono riuscita a fare molti passi avanti dal post.......adesso visualizza benissimo il minù ad albero, ma resta sempre il problema della parte grafica che vorrei cambiare e modificare:
Dalla mia ricerca ho visto che ci sono molte persone in internet che hanno probblemi di i miei stessi probblemi con il menù ad albero.
Ed allora perche non fare di questo post una specie di tutorial per tutti quelli come me che hanno cercato invano in google e non sono riusciti a trovare niente di soddisfacente.
Io posto il codice VB funzionante:
[SIZE=1][COLOR=#0000ff]
Partial[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=1] template
[/SIZE][SIZE=1][COLOR=#0000ff]Inherits[/COLOR][/SIZE][SIZE=1] Page
[/SIZE][SIZE=1][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=1] temp [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=1] cont [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Protected[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=1] Menu_Load([/SIZE][SIZE=1][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=1] sender [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=1], [/SIZE][SIZE=1][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=1] e [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1] System.EventArgs) [/SIZE][SIZE=1][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=1].Load
[/SIZE][SIZE=1][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Not[/COLOR][/SIZE][SIZE=1] IsPostBack [/SIZE][SIZE=1][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=1] nodo [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=1] TreeNode
NodoPrincipale(nodo, 1)
TreeView1.Nodes.Add(nodo)
nodo.Text = [/SIZE][SIZE=1][COLOR=#a31515]"MENU"
[/COLOR][/SIZE][SIZE=1][COLOR=#008000]'nodo.Target = ""
[/COLOR][/SIZE][SIZE=1]TreeView1.CollapseAll()
TreeView1.Nodes(0).Expand()
[/SIZE][SIZE=1][COLOR=#008000]'MsgBox.Show(Me.lbCodiceOrdine.ID.ToString(), Page)
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=1] NodoPrincipale([/SIZE][SIZE=1][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=1] nodo [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1] TreeNode, [/SIZE][SIZE=1][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=1] codicePadre [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=1])
[/SIZE][SIZE=1][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=1][COLOR=#008000]'definisco il nodo principale della treeview, caricanco le diverse tipologie di magazzini
[/COLOR][/SIZE][SIZE=1]cnGeneral.SelectCommand = [/SIZE][SIZE=1][COLOR=#a31515]"SELECT Collegamento, Titolo,codice,url,TARGET,images FROM MENU Where codicepadre=@CodicePadre ORDER BY Codice"
[/COLOR][/SIZE][SIZE=1]cnGeneral.SelectCommandType = SqlDataSourceCommandType.Text
cnGeneral.SelectParameters.Clear()
cnGeneral.SelectParameters.Add([/SIZE][SIZE=1][COLOR=#a31515]"CodicePadre"[/COLOR][/SIZE][SIZE=1], TypeCode.Int32, codicePadre)
[/SIZE][SIZE=1][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=1] dw [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1] DataView = cnGeneral.Select(DataSourceSelectArguments.Empty)
[/SIZE][SIZE=1][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=1] rowTipo [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1] DataRow [/SIZE][SIZE=1][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=1] dw.Table.Rows
[/SIZE][SIZE=1][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=1] nodeTipo [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1] System.Web.UI.WebControls.TreeNode = [/SIZE][SIZE=1][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=1] System.Web.UI.WebControls.TreeNode
[/SIZE][SIZE=1][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=1] IsDBNull((rowTipo([/SIZE][SIZE=1][COLOR=#a31515]"Url"[/COLOR][/SIZE][SIZE=1]))) [/SIZE][SIZE=1][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=1]nodeTipo.NavigateUrl = [/SIZE][SIZE=1][COLOR=#a31515]""
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Else
[/COLOR][/SIZE][SIZE=1]nodeTipo.NavigateUrl = rowTipo([/SIZE][SIZE=1][COLOR=#a31515]"Url"[/COLOR][/SIZE][SIZE=1])
[/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=1] IsDBNull((rowTipo([/SIZE][SIZE=1][COLOR=#a31515]"TARGET"[/COLOR][/SIZE][SIZE=1]))) [/SIZE][SIZE=1][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=1]nodeTipo.Target = [/SIZE][SIZE=1][COLOR=#a31515]"_self"
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Else
[/COLOR][/SIZE][SIZE=1]nodeTipo.Target = rowTipo([/SIZE][SIZE=1][COLOR=#a31515]"TARGET"[/COLOR][/SIZE][SIZE=1])
[/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=1] IsDBNull((rowTipo([/SIZE][SIZE=1][COLOR=#a31515]"images"[/COLOR][/SIZE][SIZE=1]))) [/SIZE][SIZE=1][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=1]nodeTipo.ImageUrl = [/SIZE][SIZE=1][COLOR=#a31515]""
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Else
[/COLOR][/SIZE][SIZE=1]nodeTipo.ImageUrl = rowTipo([/SIZE][SIZE=1][COLOR=#a31515]"images"[/COLOR][/SIZE][SIZE=1])
[/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=1]nodeTipo.Text = rowTipo([/SIZE][SIZE=1][COLOR=#a31515]"Titolo"[/COLOR][/SIZE][SIZE=1])
[/SIZE][SIZE=1][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=1] IsDBNull((rowTipo([/SIZE][SIZE=1][COLOR=#a31515]"collegamento"[/COLOR][/SIZE][SIZE=1]))) [/SIZE][SIZE=1][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=1]temp = 0 + rowTipo([/SIZE][SIZE=1][COLOR=#a31515]"codice"[/COLOR][/SIZE][SIZE=1])
[/SIZE][SIZE=1][COLOR=#0000ff]Else
[/COLOR][/SIZE][SIZE=1]temp = rowTipo([/SIZE][SIZE=1][COLOR=#a31515]"collegamento"[/COLOR][/SIZE][SIZE=1])
[/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=1]nodeTipo.Value = temp
nodeTipo.ToolTip = rowTipo([/SIZE][SIZE=1][COLOR=#a31515]"codice"[/COLOR][/SIZE][SIZE=1])
nodo.ChildNodes.Add(nodeTipo)
[/SIZE][SIZE=1][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Not[/COLOR][/SIZE][SIZE=1] IsDBNull((rowTipo([/SIZE][SIZE=1][COLOR=#a31515]"collegamento"[/COLOR][/SIZE][SIZE=1]))) [/SIZE][SIZE=1][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=1]NodoPrincipale(nodeTipo, temp)
[/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=1] ex [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1] Exception
[/SIZE][SIZE=1][COLOR=#008000]'Utility.ErrorLog(ex.ToString(), Page)
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Protected[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=1] TreeView1_SelectedNodeChanged1([/SIZE][SIZE=1][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=1] sender [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=1], [/SIZE][SIZE=1][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=1] e [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1] System.EventArgs) [/SIZE][SIZE=1][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=1] TreeView1.SelectedNodeChanged
[/SIZE][SIZE=1][COLOR=#008000]'MsgBox.Show(TreeView1.SelectedNode.ToolTip.ToString(), Page)
[/COLOR][/SIZE][SIZE=1][COLOR=#008000]'TreeView1.SelectedValue.ToString() + " " +
[/COLOR][/SIZE][SIZE=1][COLOR=#008000]'MsgBox.Show(TreeView1.SelectedNode.Expanded.ToString(), Page)
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=1] TreeView1.SelectedNode.Expanded.ToString() = [/SIZE][SIZE=1][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=1]TreeView1.SelectedNode.Collapse()
[/SIZE][SIZE=1][COLOR=#0000ff]Else
[/COLOR][/SIZE][SIZE=1]TreeView1.SelectedNode.Expand()
[/SIZE][SIZE=1][COLOR=#008000]'TreeView1.Nodes(0).Expand()
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Sub
End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Class
[/COLOR][/SIZE]
E naturalmente la relativa parte di pagina aspx:
[SIZE=1][COLOR=#0000ff]
<[/COLOR][/SIZE][SIZE=1][COLOR=#a31515]script[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]runat[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="server">
Protected[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=1] TreeView1_SelectedNodeChanged([/SIZE][SIZE=1][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=1] sender [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=1], [/SIZE][SIZE=1][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=1] e [/SIZE][SIZE=1][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=1] System.EventArgs)
[/SIZE][SIZE=1][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]Sub
</[/COLOR][/SIZE][SIZE=1][COLOR=#a31515]script[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]>
[/COLOR][/SIZE]
[SIZE=1][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=1][COLOR=#a31515]form[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]id[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="form1"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]runat[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="server">
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=1][COLOR=#a31515]asp[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]:[/COLOR][/SIZE][SIZE=1][COLOR=#a31515]TreeView[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]ID[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="TreeView1"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]runat[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="server"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]Height[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="550px"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]Width[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="152px"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]Font-Size[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="X-Small"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]style[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="font-family: 'Times New Roman', Times, serif;font-size: small"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]ImageSet[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="Msdn"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]NodeIndent[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="10">
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=1][COLOR=#a31515]parentnodestyle[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]font-bold[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="False"[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]/>
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=1][COLOR=#a31515]hovernodestyle[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]BackColor[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="#CCCCCC"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]font-underline[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="True"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]BorderColor[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="#888888"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]BorderStyle[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="Solid"[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]/>
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=1][COLOR=#a31515]selectednodestyle[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]backcolor[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="green"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]font-underline[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="False"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]horizontalpadding[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="3px"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]verticalpadding[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="1px"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]BorderColor[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="#888888"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]BorderStyle[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="Solid"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]BorderWidth[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="1px"[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]/>
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=1][COLOR=#a31515]nodestyle[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]font-names[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="Verdana"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]font-size[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="8pt"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]forecolor[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="Black"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]horizontalpadding[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="5px"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]nodespacing[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="1px"[/COLOR][/SIZE][SIZE=1][COLOR=#ff0000]verticalpadding[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]="2px"[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]/>
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=1][COLOR=#a31515]asp[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]:[/COLOR][/SIZE][SIZE=1][COLOR=#a31515]TreeView[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]>[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=1][COLOR=#a31515]form[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]>
[/COLOR][/SIZE]
Adesso bisognerebbe modificare la parte grafica ............ il probblema è che per ilmomento mi rendo conto di non esserne ancora capace.
Vorrei ottenere un menu simile a quello di questo sito:
http://www.unisi.it/disgeg/frame sinistro finale.htm
con l'unica differenza che vorrei che il menu si espandessi con il pasaggio del muose sopra senza cliccare la relativa voce.........
Se qualcuno volesse contribuire alla costruzione del menù io ne sarei grata.....ma penso anche molti altri utenti.
Se dovessi fare dei progresso li posto qui in modo da completare comunque il tutorial.