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();
}
Bookmarks