Click here to Skip to main content
15,916,042 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 is what I followed

how to show subitem of the menu on only clicking the parent menu not on mouse over

Pls help.
Posted
Updated 30-Sep-13 19:11pm
v2
Comments
TryAndSucceed 1-Oct-13 12:37pm    
So, how does your code look like after your changes?
anamikas 1-Oct-13 12:53pm    
This is my control -

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ServerControl1
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:ServerControl1 runat="server">")]
public class ServerControl1 : Menu
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
public string Text
{
get
{
String s = (String)ViewState["Text"];
return ((s == null) ? "[" + this.ID + "]" : s);
}

set
{
ViewState["Text"] = value;
}
}

protected override void Render(HtmlTextWriter writer)
{

StringBuilder stringBuilder = new StringBuilder();
System.IO.StringWriter stringWriter = new System.IO.StringWriter(stringBuilder);

HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
base.Render(htmlWriter);

string html = stringBuilder.ToString();
html = html.Replace("onmouseover=\"Menu_HoverStatic(this)\"", "onclick=\"Menu_HoverStatic(this)\"");

writer.Write(html);

}

}
}

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900