- Home
- Forum
- ASP.NET Web Forms
- Menu example using ASP.Net Webforms and VB.Net
Menu example using ASP.Net Webforms and VB.Net
Hi, does anyone have a complete example of creating a given menu item (not root item) and then:
- Populate the menu item from a datasource (VB.Net)
- Assign the click method so that when an item is clicked it can be processed (VB.Net ???)
- Pass the clicked item to an aspx page as a parameter to be used in code-behind (VB.Net ???)
Hi John,
As per the shared details, we understand that you need to get the clicked menu item details in the aspx page while clicking the item in the Menu control. We have prepared a simple sample of ASP.NET Web Forms VB with a Menu control to get the clicked item detail in the aspx page using the ItemClick event in the Menu control.
Using the ItemClick event, you can get the clicked menu item details like text, ID, and parent values. We have attached the prepared sample for your reference.
Refer to the below code snippet.
|
[Default.aspx]
<ej:Menu ID="menuEvents" runat="server" OnItemClick="menuEvents_ItemClick"> ... </ej:Menu> |
|
[Default.aspx.vb]
Protected Sub menuEvents_ItemClick(ByVal sender As Object, ByVal e As Syncfusion.JavaScript.Web.MenuEventArgs) Dim SelectedID = e.ID Dim ParentID = e.ParentId Dim text = e.Text End Sub |
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/WebApplication1330686606.zip
Please check the attached sample and get back to us if you need any further assistance.
Note: If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Regards,
Sivakumar S
Thank you for your help. I used your idea for a similar approach as follows:
In the Site.Master.vb page I used the following sub to populate menu:
Protected Sub FillMenuTeams()
Dim AccessConnect As String = "Provider=Microsoft.Jet.OLEDB.4.0; data source=" + Server.MapPath("App_Data\LSM.mdb") + ";Jet OLEDB:Database Password=xxxxxxxx;"
Dim conn As New OleDbConnection
Dim myReader As OleDbDataReader
Dim myCommand As New OleDbCommand
Dim sql As String
Dim sMessage As String = ""
Dim bShow As Boolean
Dim oItem As Syncfusion.JavaScript.Web.MenuItem
mnuMyTeam.Items.Clear() 'parent menu item (not root)
conn.ConnectionString = AccessConnect
conn.Open()
myCommand.Connection = conn
sql = "SELECT DISTINCT(Fixture_HomeName) FROM Fixtures WHERE Fixture_Type = 'L' ORDER BY 1 ASC"
myCommand.CommandText = sql
myReader = myCommand.ExecuteReader
If myReader.HasRows Then
While myReader.Read()
oItem = New Syncfusion.JavaScript.Web.MenuItem
oItem.Text = myReader.Item(0).ToString
oItem.Url = "MyTeam.aspx?MyTeam=" + myReader.Item(0).ToString
mnuMyTeam.Items.Add(oItem)
End While
End If
myReader.Close()
myReader = Nothing
myCommand.Dispose()
conn.Close()
conn.Dispose()
End Sub
In the receiving aspx page:
prmTeam = Request.QueryString("MyTeam")
Hi John,
We are glad that your reported query has been resolved. Please get back to us if you need any further assistance.
Regards,
Indhumathy L
- 3 Replies
- 3 Participants
- Marked answer
-
JF John Fleet
- Aug 17, 2022 12:31 PM UTC
- Aug 23, 2022 05:15 AM UTC