Results 1 to 6 of 6

Thread: How to place image to right of the menu item in asp.net?

  1. #1
    Join Date
    Nov 2009
    Posts
    67

    How to place image to right of the menu item in asp.net?

    Hi friends,
    I am working on project which has asp.net as front end. I am use asp:menu to display the items from the sitemap using the datasource Id as the sitemap name. Now one problem is there. I want to display a small triangle image on the right of the menuitem and I unable to place image to right of the menu item. Can anyone tell me how to place image to right of the menu item in asp.net? please help me.
    Thanks.

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    Re: How to place image to right of the menu item in asp.net?

    Hey it is very easy process to place image to right of the menu item in asp.net. Just put the image in the title attribute of siteMapNodes in your web.sitemap file. If you don't know how to do this then use following code.

    Code:
    <siteMapNode T="&lt;image1 S='images/frog.jpg' alt='321' &pt; Projects" url="~/project-list.aspx" description="Manage your projects">
    
    </siteMapNode>

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to place image to right of the menu item in asp.net?

    You can place image to right of the menu item through a CSS style. Just look at following example to know how to place image to right of the menu item in asp.net.
    Code:
    <%@ Page Language= "ASP.net" %>
    <head id="Head1" runat="server">
    <style type="text/css">
    .menuItem1
    {
    color:black;
    border:Solid 2px yellow;
    background-color:#c9c9c9;
    background-image : url(http://www.wallpaper.ca/images/karina.gif);
    padding:3px 6px;
    }
    </style>
    <title>Menu Templates</title>
    </head>
    <body>
    <form id="F1" runat="S">
    <div>
    
    <asp:Menu
    id="M1"
    Orientation="H"
    StaticMenuItemStyle-CssClass="menuItem1"
    DynamicMenuItemStyle-CssClass="menuItem1"
    Runat="S">
    
    <Items>
    <asp:MenuItem Text="P">
    <asp:MenuItem Text="A" />
    <asp:MenuItem Text="O" />
    </asp:MenuItem>
    <asp:MenuItem Text="B">
    <asp:MenuItem Text="S">
    <asp:MenuItem Text="C" />
    <asp:MenuItem Text="P" />
    </asp:MenuItem>
    </asp:MenuItem>
    </Items>
    </asp:Menu>
    
    </div>
    </form>
    </body>
    </html>

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: How to place image to right of the menu item in asp.net?

    I use following code for same process and it works properly. I think you also use this code to place image to right of the menu item. Here I had use url to get image.

    Code:
    <siteMapNode T="&lt;img1 src1='images/karina.jpg' alt='561' &LT; Projects" url="~/list.aspx" description="Manage projects">

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to place image to right of the menu item in asp.net?

    Hey use following code to add image to right of the menu item. It is very simple process. Just copy this code and paste it in your project then make connection as per your comfort.




    Code:
    protected void _siteMenu_ItemDataBound(object sender, System.Web.UI.WebControls.MenuEventArgs e)
    
    {
    MenuItem item1 = (MenuItem)e.Item1;
    SiteMapNode nodeFromSiteMap1 = (SiteMapNode)e.Item.DataItem;
    
    string oI = "";
    string offI = "";
    string navUrl = "";
    
    
    if (nodeFromSiteMap["iU"] != null)
    {
    oI = System.Web.HttpContext.Current.Request.ApplicationPath + System.IO.Path.Combine("/I/E/", nodeFromSiteMap["iU"]);
    offImage = System.Web.HttpContext.Current.Request.ApplicationPath + System.IO.Path.Combine("/I/E/", nodeFromSiteMap["altI"]);
    }
    nav1Url = nodeFromSiteMap["url1"];
    
    
    string src1 = offI;
    string toolTip = "";
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    System.IO.StringWriter sw = new System.IO.StringWriter();
    HtmlTextWriter htmWriter = new HtmlTextWriter(sw);
    HtmlImage image1 = new HtmlImage();
    
    image.Style.Add("b-style", "none");
    MenuItem theMenuButton = new MenuItem();
    theMenuButton.NavigateUrl = navUrl;
    image.Src = src;
    
    if (oI != "" && oI != null)
    image.Attributes["onMouseOver"] = "this.src='" + oI + "';";
    if (oI != "" && oI != null)
    image.Attributes["onMouseDown"] = "this.src='" + oI + "';";
    image.Attributes["onMouseOut"] = "this.src='" + offI + "';";
    image.RenderControl(htmWriter);
    item.Text = sw.ToString();
    }

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to place image to right of the menu item in asp.net?

    If you are using high quality image then there is no need to use URL of image. You can directly use nay of high quality image from your computer's save image. If you don't know how to add this then use following code to do this.

    Code:
     <siteMapNode url="weat.aspx" title="HomeAlone"  description="The main page" imageUrl="weat.gif">

Similar Threads

  1. Replies: 7
    Last Post: 25-03-2012, 11:30 AM
  2. start menu in wrong place
    By Beth165 in forum Customize Desktop
    Replies: 2
    Last Post: 11-06-2010, 11:16 PM
  3. Remove boot menu item ,bcdedit
    By Aditix360 in forum Operating Systems
    Replies: 4
    Last Post: 07-10-2009, 05:46 PM
  4. Add / Remove Item types from New Menu in Windows
    By Jackie in forum Customize Desktop
    Replies: 0
    Last Post: 13-12-2008, 04:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,556,172.71540 seconds with 17 queries