Rank: Newbie Groups: Member
Joined: 9/3/2008 Posts: 3
|
I am not able to populate the slide menu control from within the login page. I am using VS2008 with master pages. Once the web application is opened the user is forced to login, at this point the menu should not be populated since its populated based on the user rights level. Once the user is logged in the menu is populated using a datatable from DB.
private void PopulateMenu() { EO.Web.Menu mpMenu;
mpMenu = (EO.Web.Menu)Master.FindControl("ctl00$eoMenu"); mpMenu.Items.Clear();
DataTable dtMainTable = CreateMenuDS();
mpMenu.DataSource = dtMainTable; mpMenu.DataFields = "MenuTitle|SubMenuTitle";
EO.Web.DataBinding binding = new EO.Web.DataBinding(); binding.Depth = 1; binding.DataField = "URL"; binding.Property = "NavigateUrl";
// Add this MenuDataBinding class into the group's binding collection. mpMenu.Bindings.Add(binding);
// Populate from the data source (dsMainTable); mpMenu.DataBind();
mpMenu.SaveStateCrossPages = true; mpMenu.AutoSelectSource = EO.Web.NavigatorAutoSelectSource.NavigateUrl; mpMenu.AutoSelectTarget = EO.Web.NavigatorAutoSelectTarget.Path; } //'PopulateMenu
private DataTable CreateMenuDS() { DataSet ds = new DataSet(); string srptURL = "http://" + Request.Url.DnsSafeHost + "/reportserver/";
Session["srptURL"] = srptURL;
string sqlSTR = ("exec usp_Get_SIP_EO_Menu_Items @ContractID=" + Session["contract_number_id"].ToString() + ", @RoleID=" + Session["Role_ID"].ToString() + ", @srptURL='" + srptURL + "'"); SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["csUserLogin"].ToString()); SqlCommand cm = new SqlCommand(sqlSTR, cn); SqlDataAdapter da = new SqlDataAdapter(cm);
da.Fill(ds, "Menu");
return ds.Tables[0]; }//CreateMenuDS
The problem I am having is that nothing is showing up in the menu. The only way I get to see the slide menu populated is if I save the datatable into a session variable and then in the master page load event I populate the menu usign the session data table. Every time the master page is loaded the eoMenu.Items.Count is zero
if (!IsPostBack) { DataTable dtMainTable = (DataTable)Session["DTeoMenu"];
eoMenu.DataSource = dtMainTable; eoMenu.DataFields = "MenuTitle|SubMenuTitle";
EO.Web.DataBinding binding = new EO.Web.DataBinding(); binding.Depth = 1; binding.DataField = "URL"; binding.Property = "NavigateUrl";
eoMenu.Bindings.Add(binding); eoMenu.DataBind(); }
This to me does not look right since slide menu control will be populated every time the page is loaded. What is the best way to populate the slide menu control using master pages?
Also, how do I keep the menu item expanded even if the page that is opend is not part of the menu link? For example, I have a "user mangement" link on the menu under the admin section, once the user clicks on the "user mangemet" link of the menu you get the list of all user accounts in a datagrid, then user clicks on the edit button, but this edit button takes you to another page that is not a menu link item. How do I still keep the menu expanded to it looks like I am still in the "user Mangement" link? I thought that by setting the AutoSelectSource="ItemClick" properties would fix my issue but it does not. What am I missing?
One last question. In the slide menu properties I have set the Image-SelectedUrl="~/images/SelectedUrl.gif" the main menu, sub items, and mouse over are working but the selected item is not working, what am I doing wrong?
<eo:SlideMenu ID="eoMenu" runat="server" ControlSkinID="None" SingleExpand="False" SaveStateCrossPages="True" AutoSelectSource="ItemClick"> <LookItems> <eo:MenuItem ItemID="_TopGroup"> <SubMenu LeftIconCellWidth="10" Style-CssText="border-left-color:#beb6a4;border-left-style:solid;border-left-width:1px;border-right-color:#beb6a4;border-right-style:solid;border-right-width:1px;color:white;cursor:hand;font-family:verdana;font-size:12px;font-weight:bold;"> </SubMenu> </eo:MenuItem> <eo:MenuItem Height="28" Image-Mode="ItemBackground" Image-Url="~/images/HeaderURL.gif" ItemID="_TopLevelItem"> <SubMenu LeftIconCellWidth="10" Style-CssText="background-image:url('~/images/HeaderURL.gif');color:#37386a;font-family:Verdana;font-size:12px;font-weight:normal;"> </SubMenu> </eo:MenuItem> <eo:MenuItem Height="23" Image-HoverUrl="~/images/HoverUrl.gif" Image-Mode="ItemBackground" Image-SelectedUrl="~/images/SelectedUrl.gif" Image-Url="~/images/SubUrl.gif" ItemID="_Default" NormalStyle-CssText="" Image-SelectedHoverUrl="~/images/HoverUrl.gif"> </eo:MenuItem> </LookItems> </eo:SlideMenu>
Do you have a working sample app that uses master pages and slide menu you can send me?
Thank you in advance.
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
In order to keep menu expanded, you will need to look into AutoSelectSource, AutoSelectTarget and SaveStatesCrossPages property. When you use MasterPage, you are not really dealing with a single page. When browser switches pages all state information for the previous page are lost. These properties are there to help you to transfer some state information across page or automatically select (expand) a menu item based on the current page Url.
Thanks!
|