Click here to Skip to main content
14,639,650 members
Rate this:
Please Sign up or sign in to vote.
Hi..

As you know by default asp.net menu control opens sub items on mouse over event.

I want to change on mouse over to onclick event. so when use click on parent item, it should open subitem and on next click it should close the menu.

Please give me some tips,tricks to do the same.

Regards,
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Comments
Vijay Radia 30-May-12 1:47am
   
thanks for your respose but i already tried that javascript, but its not working once the page gets posted back.
I only need to use menu control and cant use treeview or other.
Rate this:
Please Sign up or sign in to vote.

Solution 2

Ok i got it now.

Do following :

Create one class derived from menu control.

Override render event

Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)

            Dim stringBuilder As StringBuilder = New StringBuilder()
            Dim stringWriter As StringWriter = New StringWriter(stringBuilder)

            Dim htmlWriter As HtmlTextWriter = New HtmlTextWriter(stringWriter)
            MyBase.Render(htmlWriter)

            Dim html As String = stringBuilder.ToString()

            Dim strMouseHover = "onmouseover=""Menu_HoverStatic(this)"""
            Dim strMouseClick = "onclick=""Menu_HoverStatic(this)"""

            Dim str As Boolean = html.Contains(strMouseHover)


            html = html.Replace(strMouseHover, strMouseClick)

            writer.Write(html)

        End Sub

Then overide Menu_HoverStatis(this) function as per below link:
http://forums.asp.net/t/1156758.aspx
   
v2
Comments
anamikas 1-Oct-13 1:26am
   
I have overridden the render method in a custom control, but sub menu is still not displaying when the parent menu is clicked. Pls help.
Rate this:
Please Sign up or sign in to vote.

Solution 3

I have overridden the render method in a custom control, but sub menu is still not displaying when the parent menu is clicked. Pls help.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100