Thursday 15 August 2013

c# - javascript menu items database driven -


I am using a JavaScript menu

I tried to get menu items from Database. My aspx file contains a menu and when it is a static menu it works fine, my table or my query actually arises:

  IDpage int, pageitital varchar (20) Pagefile URL varchar (30), parent image pages   

My methods data

  Datarao [] Detroopent = _DataTable Select ("[ParentIdPage] =" + 0); Leading (DataRava Dr. Parents in Detroit) {HtmlGenericControl li = New HtmlGenericControl ("li"); // Add & lt; A & gt; HtmlGenericControl hlink = New HtmlGenericControl ("a"); If (dr ["PageFileUrl"]. ToString () == "") // This item contains submenu {Li. a quality. Add ("Reliance Energy", "DDBMenu" + DR ["IDEAS"]. TOOSTING ()); Hlink.Attributes.Add ("href", "#"); // should link when hlink.InnerText = dr ["PageTitle"] is a direct link. ToString (); Li.Controls.Add (hlink); UlTopMenu.Controls.Add (Lee); AddNewUl ((int) "[" IdPage "]); AddSubmenuItems (_dataTable, (int) DR ["IDPAGE"]); } Else // Direct link, a submenu {hlink.Attributes.Add ("href", dr ["PageFileUrl"]. ToString ()); Hlink.InnerText = dr ["PageTitle"]. ToString (); Li.Controls.Add (hlink); UlTopMenu.Controls.Add (Lee); }}} Private Zero AddSubmenuItems (DataTable dataTable, int menuId) {// Create related sub menu Create DataView data = New DataView (dataTable); DataView.RowFilter = "ParentIdPage =" + MenuId; Foreach (DataViewView in DataRowView subMenuItem) {// related & lt; Ul & gt; HtmlControl ulControl = (HtmlControl) FindControl ("ddsubmenu" + menuId); // new & lt; Li & gt; & Lt; A href = "PageFileUrl.aspx" & gt; Page Title & lt; / A & gt; & Lt; / Li & gt; HtmlGenericControl li = New HtmlGenericControl ("li"); HtmlGenericControl hlink = New HtmlGenericControl ("a"); Hlink.Attributes.Add ("href", subMenuItem ["PageFileUrl"]. ToString ()); Hlink.InnerText = subMenuItem ["PageTitle"]. ToString (); Li.Controls.Add (hlink); Li.Intertext = Submenuite ["Pagtitital"]. Toasting (); Li.Attributes.Add ("href", subMenuItem ["PageFileUrl"]. ToString ()); UlControl.Controls.Add (Lee); }} Private Zero AddNewUl (int menuId) {// Add new & lt; Ul id = "ddsubmenu00" class = "ddsubmenustyle" & gt; HtmlGenericControl newUl = New HtmlGenericControl ("UL"); // Set NewUl Properties NewUl.ID = "ddsubmenu" + Menu ID; NewUl.Attributes.Add ("class", "ddsubmenustyle"); PlaceHolder1.Controls.Add (newUl); }   

My problem is that the submenu does not appear! What is wrong? Any help appreciated

Thanks for all, finally I thought:
this line Change to

  li.Attributes.Add ("rel", "" + "ddsubmenu" + [["IDPAGE"]. ToString () + "");   

with one:

  hlink.Attributes.Add ("rel", "" + "ddsubmenu" + dr ["idpage"]. ToString () + "");   

Now it works properly: -)

No comments:

Post a Comment