Menu dinamico - sessioni - placeholder...HELP

venerdì 04 luglio 2008 - 17.14

stuzzo Profilo | Junior Member

Salve a tutti!
ho un problemino da cui non riesco ad uscire......o forse non mi rendo conto di cosa devo fare :)
Sto creandomi un sito che ha sulla sinistra un menù. Questo menù in base se si è loggati o meno deve cambiare o meglio se si è loggati questo menù viene arricchito di altre voci, ma il resto è tutto uguale.
Adesso cosa mi consigliate di fare??
Visto che si trova all'interno di un content placeholder:
- dovrei soltanto rendere invisibili le voci e nel caso si è loggati renderle visibili? oppure
- dire al content di andarsi a caricare un altro menù? oppure
- crearmi un menù dinamico che se si è loggati aggiunge delle voci? (questa mi sembra più sensata, ma non ho idea di come fare)

Vi ringrazio anticipatamente di tutto!

Mikyct86 Profilo | Junior Member

Allora l'ultima è la piu sensata!
Crei un Menu e ti basta aggiungere al login una variabile di sessione tipo session("ClientId")=1
alla creazione del Menu dove crei le voci basta dire che Se session("ClientId") > 0 crei le voci nuove!

Ciao,
«Due cose sono infinite: l'universo e la stupidità umana, ma riguardo l'universo ho ancora dei dubbi.» A.E.
Michele Crimi - Programmatore .Net

stuzzo Profilo | Junior Member

Ti ringrazio,
riusciresti a postarmi un pezzetto di codice di come creare il menu?
Grazie mille ancora

Mikyct86 Profilo | Junior Member

Io ho un menu creato da una Stored Procedure fatto tempo fa...Vedi se ti puo aiutare!

questo script creava un controllo di tipo menu... se hai dubbi non esitare a contattarmi!

Public Sub CreaMenu()
Dim menu1 As New Menu
menu1.Items.Clear()
Dim FatherItem As New MenuItem
Dim ChildItem As New MenuItem
Dim dr As DataRow
Dim CatName As String
Dim ProdName As String
Dim prod As Integer
Dim cat As Integer
Dim discTemp As Integer
Dim i As Integer
Dim altezza As Integer = 0
Dim dtaEventType As DataTable = DataInterface.DBCategorie.cp_GetCategorieAndProdotti
For Each dr In dtaEventType.Rows
ChildItem = New MenuItem

cat = dtaEventType.Rows.Item(i).Item(2)
prod = dtaEventType.Rows.Item(i).Item(3)
CatName = dtaEventType.Rows.Item(i).Item(0)
'maiuscolo
CatName = CatName.ToUpper()
ProdName = dtaEventType.Rows.Item(i).Item(1)
ProdName = GetEventTextAbbreviation(ProdName)

'se non è il primo
If i > 0 Then
'il precedente
discTemp = dtaEventType.Rows.Item(i - 1).Item(2)
Else
altezza += 30
FatherItem = New MenuItem
'se è il primo
With FatherItem
.Text = CatName & "(" & dtaEventType.Rows.Item(i).Item(4) & ")"
.Value = cat

.NavigateUrl = "../Products.aspx?CategoriaID=" & cat & "&ProdottoID=-1&bShowAll=1"
End With
With ChildItem
.Text = ProdName
.Value = prod

.NavigateUrl = "../Products.aspx?CategoriaID=" & cat & "&ProdottoID=" & prod & "&bShowAll=1"
End With
'A seconda se è loggato inserisco il child Item
if session("lClientID")>0 then
FatherItem.ChildItems.Add(ChildItem)
end if


With menu1
.Items.Add(FatherItem)
End With
End If
If i > 0 Then
If discTemp <> cat Then
FatherItem = New MenuItem
With FatherItem
.Text = CatName & "(" & dtaEventType.Rows.Item(i).Item(4) & ")"
.Value = cat
.NavigateUrl = "../Products.aspx?CategoriaID=" & cat & "&ProdottoID=-1&bShowAll=1"
End With
With ChildItem
.Text = ProdName
.Value = prod
.NavigateUrl = "../Products.aspx?CategoriaID=" & cat & "&ProdottoID=" & prod & "&bShowAll=1"
End With
FatherItem.ChildItems.Add(ChildItem)
altezza += 30
With menu1
.Items.Add(FatherItem)
End With
Else
With ChildItem
.Text = ProdName
.Value = prod
.ToolTip = ProdName
.NavigateUrl = "../Products.aspx?CategoriaID=" & cat & "&ProdottoID=" & prod & "&bShowAll=1"
End With
FatherItem.ChildItems.Add(ChildItem)
End If
End If
i += 1
Next
With menu1
.DynamicMenuItemStyle.CssClass = "lTop2"
.Height = Unit.Pixel(altezza)
.Width = Unit.Pixel(100)
.StaticMenuItemStyle.CssClass = "lMenu2"
.StaticSubMenuIndent = Unit.Pixel(30)
.DynamicVerticalOffset = 0
End With
UpdatePanel1.Controls.Add(menu1)
End Sub

Ciao,



«Due cose sono infinite: l'universo e la stupidità umana, ma riguardo l'universo ho ancora dei dubbi.» A.E.
Michele Crimi - Programmatore .Net

sankyu Profilo | Senior Member

Potresti anche usare gli oggetti autentication di asp.net che fai prima !!!
leggiti: http://dotnethell.it/articles/Membership-Role-Profile-Provider.aspx
e poi anche info sulla loginview che è il componente che serve a te!
http://msdn.microsoft.com/it-it/library/system.web.ui.webcontrols.loginview.aspx

perchè sbattersi quando ms ha gia fatto il lavoro!!

oppure puoi creare dei menu usando il db ma è un lavoraccio!
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-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5