Hi I want that when i take the mouse over the menu, I dont want to show submenu.the submenu should only be display on clicking the parent item. I have writen code as
<asp:Menu ID="Menu1" runat="server" BackColor="#FFFBD6" DynamicHorizontalOffset="2"
Font-Names="Verdana" Font-Size="0.8em" ForeColor="#990000" Orientation="Horizontal" StaticSubMenuIndent="10px" Style="z-index: 112; left: 205px;
position: absolute; top: 14px">
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#990000" ForeColor="White" />
<DynamicMenuStyle BackColor="#FFFBD6" />
<StaticSelectedStyle BackColor="#FFCC66" />
<DynamicSelectedStyle BackColor="#FFCC66" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticHoverStyle BackColor="#990000" ForeColor="White" />
</asp:Menu>
and in the code behinde file as protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
DataTable dt = new DataTable();
DataTable dt1 = new DataTable();
// DataTable dt2 = new DataTable();
TextBox3.Visible = false;
Label3.Visible = false;
Label2.Text = "Password";
// Menu m = new Menu();
string cn = "Data Source=hcl;Initial Catalog=mydata;Integrated Security=True";
SqlConnection con = new SqlConnection(cn);
SqlCommand cmd = new SqlCommand("select parentname,id from menu ", con);
con.Open();
cmd.CommandType = CommandType.Text;
SqlDataReader dr = cmd.ExecuteReader();
dt.Load(dr);
for (int count = 0; count < dt.Rows.Count; count++)
{
MenuItem mnuLinkItem = new MenuItem();
mnuLinkItem.Text = dt.Rows[count]["parentname"].ToString();
mnuLinkItem.Value = dt.Rows[count]["id"].ToString();
string menuid = mnuLinkItem.Value;
// mnuLinkItem.NavigateUrl = datatable.Rows[count][1].ToString();
Menu1.Items.Add(mnuLinkItem);
string str = "select subname from submenu where subid=" + menuid + "order by menuorder asc";
SqlCommand cmd1 = new SqlCommand(str, con);
cmd1.CommandType = CommandType.Text;
SqlDataReader dr1 = cmd1.ExecuteReader();
dt1 = new DataTable();
dt1.Load(dr1);
int count2 = dt1.Rows.Count;
for (int j = 0; j < count2; j++)
{
MenuItem mnuLinkItem1 = new MenuItem();
mnuLinkItem1.Text = dt1.Rows[j]["subname"].ToString();
mnuLinkItem.ChildItems.Add(mnuLinkItem1);
// mnuLinkItem.NavigateUrl = datatable.Rows[count][1].ToString();
// mnuLinkItem1.ChildItems.AddAt(count2, mnuLinkItem1); //meun.Items.Add(mnuLinkItem);
//Menu1.Items.AddAt(count2, mnuLinkItem1);
//dr2.Close();
}
}
con.Close();
}
}
Please help I want a exact code for it please help..