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:

  1. Populate the menu item from a datasource (VB.Net)
  2. Assign the click method so that when an item is clicked it can be processed (VB.Net ???)
  3. Pass the clicked item to an aspx page as a parameter to be used in code-behind (VB.Net ???)
I cannot find any examples anywhere.

Many thanks, John

3 Replies 1 reply marked as answer

SS Sivakumar ShunmugaSundaram Syncfusion Team August 18, 2022 03:05 PM UTC

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



JF John Fleet August 19, 2022 03:46 PM UTC

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")



Marked as answer

IL Indhumathy Loganathan Syncfusion Team August 23, 2022 05:15 AM UTC

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


Loader.
Up arrow icon