Thursday, April 06, 2006

To get windows authenticated username

imports System.Security

Dim authUserName As String
Dim aspUserName As String
'authUserName = User.Identity.Name
'aspUserName = Principal.WindowsIdentity.GetCurrent.Name
'authUserPrincipalLabel.Text = "You are: " & authUserName
'aspPrincipalLabel.Text = "This page runs as: " & aspUserName
authUserName = User.Identity.Name
aspUserName = Principal.WindowsIdentity.GetCurrent.Name
authLbl.Text = "You are: " & authUserName
aspLbl.Text = "This page runs as: " & aspUserName

to build dynamic tree view in asp.net 2.0

Dim treeview2 As New TreeView
treeview2.EnableClientScript = True
treeview2.PopulateNodesFromClient = True
Dim i, j As Integer
Dim ds1 As New DataSet
ds1 = objtest05.fnLoadempdetails(strconn)
i = ds1.Tables(0).Rows.Count

Dim root1(i) As TreeNode
Dim child(i) As TreeNode

j = 0
While j < i
root1(j) = New TreeNode
'root1(j).PopulateOnDemand = True
child(j) = New TreeNode
' child(j).PopulateOnDemand = True
Dim s, s1 As String
s = CStr(ds1.Tables(0).Rows(j).Item(0))
s1 = CStr(ds1.Tables(0).Rows(j).Item(1))
root1(j).Text = s
child(j).Text = s1
root1(j).ChildNodes.Add(child(j))
treeview2.Nodes.Add(root1(j))
PlaceHolder1.Controls.Add(treeview2)
j = j + 1
End While