Click here to Skip to main content
Sign Up to vote bad
good
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:34


2 solutions

  Permalink  
Comments
Vijay Radia - 30 May '12 - 1:47
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.
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  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 464
1 Mahesh Bailwal 373
2 Maciej Los 215
3 Rohan Leuva 175
4 CPallini 175
0 Sergey Alexandrovich Kryukov 9,402
1 OriginalGriff 7,204
2 CPallini 3,933
3 Rohan Leuva 3,211
4 Maciej Los 2,743


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 30 May 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid