.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Dynamically Generated Dynamic Menu Items Width Question

Posted By:      Posted Date: September 21, 2010    Points: 0   Category :ASP.Net

I have the following Menu:

<asp:Menu ID="MainMenu" runat="server" Orientation="Horizontal" 
	DynamicVerticalOffset="2" DynamicHorizontalOffset="2" 
	StaticEnableDefaultPopOutImage="false" DynamicEnableDefaultPopOutImage="false" >
        <StaticMenuItemStyle BackColor="#0099cc" ForeColor="#eeeeee" Font-Names="Arial" Font-Size="11" Height="18" HorizontalPadding="10" VerticalPadding="3"  />
	<StaticHoverStyle BackColor="#336699" ForeColor="#ffffff" Font-Names="Arial" Font-Size="11" />
	<DynamicMenuItemStyle BackColor="#0099cc" ForeColor="#eeeeee" Font-Names="Arial" Font-Size="10" Height="18" 
		HorizontalPadding="10" VerticalPadding="3" />
	<DynamicHoverStyle BackColor="#336699" ForeColor="#ffffff" Font-Names="Arial" Font-Size="10" />					
		<asp:MenuItemBinding DataMember="Item" TextField="Title" />
		<asp:MenuItemBinding DataMember="SubItem" TextField="Title" />						

View Complete Post

More Related Resource Links

Menu with Static and Dynamic Menu Items

I need to populate a menu with static and dynamic (at runtime) menu items.  I know this issue has been posted before, but I haven't seen anything with a date newer than 2009. This is what I want to do: <Menu> <Menu.ItemsSource>                     <CompositeCollection>                      <MenuItem Header="Menu Item 1" /> <MenuItem Header="Menu Item 2" /> <MenuItem Header="Menu Item 3" />                         <CollectionContainer Collection="{Binding MyMenuItems}" />                     </CompositeCollection> </Menu.ItemsSource> </Menu>   The posts every where say the issue is that CompositeCollection is not freezable.  Regardless of that arguement, has anyone come up with a good solution.  I don't want to create it all in code behind because it is a decent size menu with separators, etc.  This seems like something that should have been fixed or have a decent work round by now.   Thanks. 

Charset Problem with dynamically generated Word Document


in my asp.net web application i am dynamically generating a word documnet out of a sql data. I have set the char set UTF-8 during the doument creation in code but still when i open the generated document and check it char set .. it is always windows-1252 not the one that i have set. My sql data in the document have special characters whihc can only be understandable using the UTF-8 charset otherwise its always ?T written in place of an apostrophy . Pasting my code here..

         HttpContext.Current.Response.ContentType = "application/msword";
         HttpContext.Current.Response.ContentEncoding = System.Text.UnicodeEncoding.UTF8;
         HttpContext.Current.Response.Charset = "utf-8";
         string strFileName = "Details" + ".doc";
        HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);
        StringBuilder strHTMLContent = new StringBuilder();
        string strMessage = " ";
        DataView abstractview = (DataView)dsAbstract.Select(DataSourceSelectArguments.Empty);
        foreach (DataRowView row1 in abstractview)
            strMessage += "<table border='1' cellspacing='0' cellpadding='5' width

Dynamic menu control


Dear all,

I want to get the names of some folders in my drive and populate my menu control with the names of those folders.

Getting the folder names is not the issue, but how can i populate my menu with the names of getted foldernames.

I tried this:

DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath("~\\MyFolders\\"));
DirectoryInfo[] dirs = dirInfo.GetDirectories();
Menu1.DataSource = dirs;

But im getting the error:

HierarchicalDataBoundControl only accepts data sources that implement IHierarchicalDataSource or IHierarchicalEnumerable.


How can i achieve this?

Thanks in advance.


Menu items of Welcome control behaves incorrect in non-IE browsers.


We are using wss 3.0 sp2

I am referring to the welcome control that is part of standard sharepoint pages. This is the in the masterpage. The welcome contrrol has options such as 'sign-in as different user' , 'signout' and so on. When user takes the mouse and tries to click on the sub-menu it doesn't work as if the menu item is not getting focussed (however up/down arrow with keyboard works fine). 

I know that sharepoint sites are not best when viewed with firefox, safari, chrome etc  but is there a fix for this? Is it do with 'z' index setting or something? Can this be fixed through javascript?  

Please share your views/solution.


How to Make CSS for Hyperlinks NOT Affect Menu Items


VWD 2008 Express.

I have the following CSS in my DefaultStyleSheet.css file.  I want this to only apply to text hyperlinks (like links to web sites or email addresses) but NOT to my asp:menu items.  I am finding that although I have defined my asp:menu items in the menu properties, the colors in the text in the menu tabs get overridden by the CSS below.  How can I make this not happen?  Thanks for any help.


{color:#6F928B; text-decoration: none}


{color: #660066;}


Jquery dynamic Category menu


Dear Friends

Im currently developing ecommerce web site. I reffered to some video tutorials in ASP.net website and i managed to develped basic store front for my ecommerce website. I would like give more attractive look to my categories menu using Jquery or ajax. Please someone help me to understand how to apply jquery or ajax to dynamic category menu.

I use web user control to create category menu. This is my code for that.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CategoriesList.ascx.cs" Inherits="UserControls_CategoriesList" %>
<asp:DataList ID="list" runat="server" CssClass="CategoriesList" Width="200px">
    Choose a Category
  <HeaderStyle CssClass="CategoriesListHead" />
    <asp:HyperLink ID="HyperLink1" Runat="server"
      NavigateUrl='<%# Link.ToCategory(Request.QueryString["DepartmentID"], Eval("CategoryID").ToString()) %>'
      Text='<%# HttpUtility.HtmlEncode(Eval("Name").ToString()) %>'
      ToolTip='<%# HttpUtility.HtmlEncode(Eval("Description").ToString()) %>'

How to create a dynamically populated items in a listbox and use it as a navigation?

Hello, I am trying to create navigation inside a listbox menu. I load data from xml to populate a list. Each item in the list box should be a link or button. Then, I create a frame to load xaml pages in it. I tested to load pages employing button control, outside listbox with on click event and it worked well. However, I cannot make it work with list box items. I am hoping to get help from you. Any sample or ideas are highly appreciated. Below is the code:  XML: <?xml version="1.0" encoding="utf-8"?> <Pages> <page id="page01"> <name>Page 01</name> </page> <page id="page02"> <name>Page 02</name> </page> </Pages> C# to initiate a click o n listbox item and get the path to page: private void SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem); string itemName = lbi.Content.ToString(); if ( Nav_ListBox.SelectedItem.Equals("Page01" ) ) { ContentFrame.Source = new Uri("Pages/Page01.xaml", UriKind.RelativeOrAbsolute); } } XAML:  <ListBox x:Name="Nav_ListBox" Margin="0" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Background="#FFF2F2F2" ItemTemplate="{DynamicReso

dynamic menu control call in login page

Hi ,i have declared two control in my master page , how wants to call this menu control in child page ( that is login page)i want to bind the menu control dynamically based on login previlagepublic Menu newMenu = new Menu();  public MenuItem newItem = new MenuItem("Master");

Cannot retrieve values of dynamically generated controls

Hi All, I am creating a user control which contains checkboxes and labels that needs to be created on fly. The dynamic generation of these controls depend on the values retreived from a SPlist. I have several panels that display items queried from the list on the basis of a selection criteria. On a button click event I need to capture all the selected values from the controls that were generated dynamically.  When I traverse each dynamic control that I added to the panel, I dont see their values. I tried using recursive retrieval of the control from the page as well but it just behaves crazy, it treats a radio button as a checkbox and returns a value that I am not looking for. I am not using the the page_load() or any other event, I use the button handler on my custom method. I was thinking for ViewState, ControlsState or SessionState. I assume ViewState may not work on this as the dynamically generated controls need to be in the page_load event. Please guide as this getting way more complicated than what I had ever thought of it to be.

Customize SharePoint Library Menu Items

Hi, In a library with file, the menu items available for any file is: View Properties, Edit Properties, Manage Permissions, Edit in <ApplicationName>, Delete, Send To, Check Out, Workflows, Alert Me . Now, I want to get rid of Edit Properties, Manage Permissions, Edit in <ApplicationName>, Delete, Check Out . Added to this is the need to remove the option in the Actions menu that states "Open With Windows Explorer " and finally the "Upload " menu is to go out. Any JScript for this or a file I need to edit to get this result? I need this because the business wants it out, its bordering on security. ThanksYou've only got one life; help as many people as you can, and enjoy it while it lasts.

Handling event from dynamically generated ImageButtons

Dear all,I have a situation here.Please review the following codeImports MySql.Data.MySqlClient Imports VB = Microsoft.VisualBasic Partial Class AddFriend Inherits System.Web.UI.Page Dim WithEvents btnAccept As ImageButton Dim WithEvents btnReject As ImageButton Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init Dim ConnectionString As String ConnectionString = ConfigurationManager.ConnectionStrings("MySqlConnectionString").ToString.Trim Dim MySqlConnection As New MySqlConnection(ConnectionString) Try MySqlConnection.Open() Dim MySqlCommand As New MySqlCommand("", MySqlConnection) MySqlCommand.CommandText = "Select `ccf`.uuid,`ccf`.requestmsg,`cu`.* from `chittochat`.`cc_friends` as `ccf`, `chittochat`.`cc_users` as `cu` where `cu`.uuid=`ccf`.uuid and `ccf`.fuuid='" & Membership.GetUser(Page.User.Identity.Name.Trim).ProviderUserKey.ToString & "' and `ccf`.accepted=0" Dim Reader As MySqlDataReader = MySqlCommand.ExecuteReader If Reader.HasRows Then Do While Reader.Read() Dim img As New Image With {.Height = 40, .Width = 35, .ImageUrl = "content\userphoto\" & Reader("PhotoURL").ToString.Trim & Reader("PhotoEXT"

Dynamically adding User Controls -- newbie question!

I am new to ASP.NET (coming from ColdFusion, thank goodness I'm away from that!).  And I am have THE hardest time understanding how to work with forms in ASP.NET.  Here's what I am doing:Dynamically add User Controls to a PlaceHolder based on some int value (which currently is passed in a HiddenField).Fire an event if the WebControls inside of the User Control change, then handle that event in the Main Page (i.e. save the input to DB)When the user clicks the "Next/Continue" button, the next controls for the next page are loaded.And I guess maybe I just can't seem to get how things work in ASP.NET, because I am really struggling with the general idea of how ASP.NET flows.  Should I be dynamically loading the controls in Page_Init, or Page_Load?  Or should I load the controls when the buttonclick event is fired?Do I have to add the axCtrl.OnDataChange += new EventHandler(HandleAxControlDataChange); line on Page_Load?  Or should I put this in When I first load the UserControl, I need to initialize some WebControls within the UserContorl.  Is there a way to know if I have loaded new user controls into my placeholder?  I can't use Page.IsPostback, because after the first page, every page is a postback from the buttonclick.Any help for this confused newbie would be GREATLY appreciated!!Here's what I have: pu

WPF: Adding checkbox with content Textblock at dynamically - width width returns NaN

I want to add set of checkbox at runtime one by one in one column. So i am creating check box object with content Textblock (Textwrapping = wrap) and adding to wrappanel but width of controls is NaN so i am not able to set location(Y co ordinate) of next checkbox. int lastheight = 10; private void btnadd_Click(object sender, RoutedEventArgs e) { CheckBox chk_add = new CheckBox(); chk_add.MaxWidth = 100; TextBlock tb_add = new TextBlock(); tb_add.MaxWidth = 100; tb_add.TextWrapping = TextWrapping.Wrap; tb_add.Text = "Here is long text so that text block will get split over two lines....... blah blah blah"; chk_add.Content=tb_add;     chk_add.Margin = new Thickness(10, lastheight, 0, 0); wrapPanel1.Children.Add(chk_add); lastheight += (int)chk_add.Width; } Can any any one have idea how can i tackle this issue.

Menu Items for SPMenu

Hi All, I have developed application page which contains spgridview. And I have used SPMenuField for displaying menu items for files and folders. What my problem is, for both  files and folders I am getting same menu items. But I need to display different menu items for folders and files based on condition. How can I achieve this? Let me know if you have any queries. Regards, Kumar.

How To Space Menu Items Evenly

I'm using Visual Studio 2008. I have a asp menu in a cell in a table. The menu has 3 items as shown below This works fine however, how do you put more spacing (even spacing) bewteen the items? The items are too close together.   <tr>        <td>        </td>        <td>        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal"                 style="margin-right: 8px">            <Items>                <asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>                <asp:MenuItem Text="Solutions" Value="Solutions"></asp:MenuItem>                <asp:MenuItem Text="Contact" Value="Contact"></asp:MenuItem>            </Items>  

After building Installer - Items missing from Menu

Not sure if this is the best or correct forum so please excuse me and let me know where I should be posting my question, thanks. I have built my Windows Forms Application and it works fine... I now have to build an Installer project, which I have done with  reasonable success... EXCEPT FOR... The Menu Group and item do NOT appear in the Menu system.  The Desktop item appears correctly and the structure is there but no menu items appear.  I created the shortcut for the User's Desktop and User's Program Menu. (Using VS2008, C#, .NET 3.51, Access (DB), Forms, Installer project.) What am I missing SquireDude

Collect Menu/Submenu/Popupmenu items

Dear Sir, I am using VS2005 and SQL Server2000 I have a project where lot of Menu/Submenu/Popupmenu items. Now I want to have all Menu/Submenu/Popupmenu items in a list box of the project. I want to do this for create user access control to my project. so that selective group can access selected feature and Menu/Submenu/Popupmenu items. How can I do this ?????? / or is there any other way to control this access????
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend