Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET1.0 .NET1.1 .NET2.0 .NET3.0 , +
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 29-May-12 19:34pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Vijay Radia at 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: bad
good
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
  Permalink  
v2
Comments
anamikas at 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: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 470
1 Gihan Liyanage 317
2 ClimerChinna 182
3 vikinghunter 176
4 OriginalGriff 141
0 Sergey Alexandrovich Kryukov 8,653
1 OriginalGriff 7,132
2 CPallini 2,598
3 Richard MacCutchan 2,060
4 Abhinav S 1,808


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 1 Oct 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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