thanks for intersting , about all the controls added dynamically exept (panel1,panel2,panel3) and this is all the code
vb code
Imports DotNetNuke
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Collections.Generic
Imports System.Reflection
Imports System.Text
Imports DotNetNuke.Security.PortalSecurity
Partial Class DesktopModules_test_Test
Inherits Entities.Modules.PortalModuleBase
'Dim panel As New Panel
'Dim panelString As StringBuilder
Dim PopUpPanel As New Panel
Dim linkBtnChild As New LinkButton
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'for DB
Dim myConnection As SqlConnection = New SqlConnection("server=ISITC-A31266378;uid=dnnuser40;pwd=1311984;database=DotNetNuke40")
Dim myCommand As SqlCommand
Dim dr As SqlDataReader
Try
If DotNetNuke.Framework.AJAX.IsInstalled Then
DotNetNuke.Framework.AJAX.RegisterScriptManager()
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
'establishing connection. you need to provide password for sql server
myConnection.Open()
'opening the connection
myCommand = New SqlCommand("SELECT TabID, TabName FROM Tabs WHERE ParentID = 63", myConnection)
'executing the command and assigning it to connection
dr = myCommand.ExecuteReader()
Dim i As Integer = 0
Dim j As Integer = 0
Dim tab() As Integer = {0, 0, 0}
Dim tabPopUpName As String() = New String(3) {"1", "2", "3", "4"}
While dr.Read()
'menu hover
tab(i) = dr(0)
'Response.Write(tab(i))
i = i + 1
Dim menu As New AjaxControlToolkit.HoverMenuExtender
menu.ID = "HoverMenuExtender" & dr(1).ToString
menu.TargetControlID = "btn" & dr(1).ToString
menu.PopupControlID = "PanelPopUp" & dr(1).ToString
'menu.PopupPosition = AjaxControlToolkit.HoverMenuPopupPosition.Bottom
menu.OffsetX = 6
menu.PopDelay = 25
menu.HoverCssClass = "popupHover"
Panel3.Controls.Add(menu)
'linkBtn
Dim linkBtn As LinkButton
linkBtn = New LinkButton
linkBtn.ID = "btn" & dr(1).ToString
linkBtn.Text = dr(1).ToString
Panel2.Controls.Add(linkBtn)
'panel child
'Dim PopUpPanel As New Panel
PopUpPanel.ID = "PanelPopUp" & dr(1).ToString
'Response.Write(PopUpPanel.ID.ToString)
tabPopUpName(j) = "PanelPopUp" & dr(1).ToString
'Response.Write(tabPopUpName(j))
j = j + 1
PopUpPanel.CssClass = "popupMenu"
PopUpPanel.Width = 373
PopUpPanel.Height = 22
Panel1.Controls.Add(PopUpPanel)
End While
dr.Close()
myConnection.Close()
'#############################################################################################################################
' For Each panelTab As String In tabPopUpName
'panel.ID = panelTab
'panel.CssClass = "popupMenu"
'panel.Width = 373
'panel.Height = 22
'panel.BackColor = Color.Chocolate
'Panel1.Controls.Add(panel)
'Response.Write(Parent)
For Each Parent As Integer In tab ''''''
'establishing connection. you need to provide password for sql server
myConnection.Open()
'opening the connection
myCommand = New SqlCommand("SELECT TabName FROM Tabs WHERE ParentID = " & Parent, myConnection)
'executing the command and assigning it to connection
dr = myCommand.ExecuteReader()
While dr.Read()
'Response.Write(dr(0))
'linkBtnChild
linkBtnChild.ID = "Btn" & dr(0)
linkBtnChild.CausesValidation = "true"
linkBtnChild.CommandName = dr(0).ToString
linkBtnChild.Text = dr(0).ToString
'adding buttun to panel
PopUpPanel.Controls.Add(linkBtnChild)
End While
dr.Close()
myConnection.Close()
Next
'Next
End Sub
Protected Sub DropDownListAddMenu_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim DropDownListAddMenu As DropDownList = formView1.FindControl("DropDownListAddMenu")
Dim LblAddMenuChoiced As Label = formView1.FindControl("LblAddMenuChoiced")
LblAddMenuChoiced.Text = DropDownListAddMenu.SelectedValue
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim DropDownListAddParent As DropDownList = formView1.FindControl("DropDownListAddParent")
Dim LblAddParentChoiced As Label = formView1.FindControl("LblAddParentChoiced")
LblAddParentChoiced.Text = DropDownListAddParent.SelectedValue
End Sub
Protected Sub InsertItemButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
Protected Sub InsertCancelButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
Protected Sub LinkButtonAddMenu_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButtonAddMenu.Click
Me.formView1.Visible = True
End Sub
End Class
this is the ascx
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Test.ascx.vb" Inherits="DesktopModules_test_Test" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<style type="text/css">
.popupMenu {
position:absolute;
visibility:hidden;
background-color:#AAFFFF;
opacity:.9;
filter: alpha(opacity=90);
}
.popupHover {
background-image:url(images/header-opened.png);
background-repeat:repeat-x;
background-position:left top;
background-color:#F5F7F8;
}
</style>
<asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
</asp:Panel>
<asp:Panel ID="Panel2" runat="server" Height="36px" Width="648px" BackColor="silver">
</asp:Panel>
<asp:Panel ID="Panel3" runat="server" Height="50px" Width="125px">
</asp:Panel>
<br />
<asp:formView ID="formView1" runat="server"
DataKeyNames="MenuID"
DataSourceID="SqlDataSource1"
DefaultMode="Insert" Visible="False" CellPadding="4" ForeColor="#333333">
<EditItemTemplate>
</EditItemTemplate>
<InsertItemTemplate>
<table>
<tr>
<td style="width: 100px">
<asp:Label ID="LblAddMenu" runat="server" Text="add menu" Width="102px"></asp:Label></td>
<td style="width: 24px">
</td>
<td style="width: 100px">
<asp:DropDownList ID="DropDownListAddMenu" runat="server" DataSourceID="SqlDataSource2"
DataTextField="TabName" DataValueField="TabID" OnSelectedIndexChanged="DropDownListAddMenu_SelectedIndexChanged">
</asp:DropDownList></td>
<td style="width: 158px">
<asp:Label ID="LblAddMenuChoiced" runat="server" Width="115px" text='<%# Bind("TabID") %>'></asp:Label></td>
</tr>
<tr>
<td style="width: 100px">
<asp:Label ID="LblAddParent" runat="server" Text="add Parent" Width="99px"></asp:Label></td>
<td style="width: 24px">
</td>
<td style="width: 100px">
<asp:DropDownList ID="DropDownListAddParent" runat="server" DataSourceID="SqlDataSource2"
DataTextField="TabName" DataValueField="TabID" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList></td>
<td style="width: 158px">
<asp:Label ID="LblAddParentChoiced" runat="server" Width="142px" text='<%# Bind("ParentID") %>'></asp:Label></td>
</tr>
<tr>
<td style="width: 100px; height: 21px;">
</td>
<td style="width: 24px; height: 21px;">
</td>
<td style="width: 100px; height: 21px;">
<asp:LinkButton ID="InsertItemButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert" OnClick="InsertItemButton_Click">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel" OnClick="InsertCancelButton_Click">
</asp:LinkButton>
</td>
<td style="width: 158px; height: 21px">
</td>
</tr>
</table>
<br />
<br />
<br />
</InsertItemTemplate>
<ItemTemplate>
</ItemTemplate>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
</asp:formView>
<br />
<asp:LinkButton ID="LinkButtonAddMenu" runat="server">add menu</asp:LinkButton><br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="MenuID" DataSourceID="SqlDataSource1" EmptyDataText="Il n'y a aucun enregistrement de données à afficher."
ForeColor="#333333" GridLines="None">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="MenuID" HeaderText="MenuID" ReadOnly="True" SortExpression="MenuID" />
<asp:BoundField DataField="TabID" HeaderText="TabID" SortExpression="TabID" />
<asp:BoundField DataField="ParentID" HeaderText="ParentID" SortExpression="ParentID" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DotNetNuke40ConnectionString1 %>"
DeleteCommand="DELETE FROM [Menu] WHERE [MenuID] = @MenuID" InsertCommand="INSERT INTO [Menu] ([TabID], [ParentID]) VALUES (@TabID, @ParentID)"
ProviderName="<%$ ConnectionStrings:DotNetNuke40ConnectionString1.ProviderName %>"
SelectCommand="SELECT [MenuID], [TabID], [ParentID] FROM [Menu]" UpdateCommand="UPDATE [Menu] SET [TabID] = @TabID, [ParentID] = @ParentID WHERE [MenuID] = @MenuID">
<DeleteParameters>
<asp:Parameter Name="MenuID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="TabID" Type="Int32" />
<asp:Parameter Name="ParentID" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="TabID" Type="Int32" />
<asp:Parameter Name="ParentID" Type="Int32" />
<asp:Parameter Name="MenuID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="TabID" DataSourceID="SqlDataSource2" EmptyDataText="Il n'y a aucun enregistrement de données à afficher."
ForeColor="#333333" GridLines="None">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="TabID" HeaderText="TabID" ReadOnly="True" SortExpression="TabID" />
<asp:BoundField DataField="TabName" HeaderText="TabName" SortExpression="TabName" />
<asp:BoundField DataField="ParentId" HeaderText="ParentId" SortExpression="ParentId" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DotNetNuke40ConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:DotNetNuke40ConnectionString1.ProviderName %>"
SelectCommand="SELECT * FROM [Tabs]"></asp:SqlDataSource>
<br />