joseaardvark
New Member
I've a helper like this, I created this using raw HTML inside as follows:\[code\]private static readonly Core Db = new Core(); // Main menupublic static MvcHtmlString MainMenu(){ IQueryable<Page> primaryPages = Db.Pages.Where(p => p.IsItShowInMenu); var sb = new StringBuilder(); sb.Clear(); string pagecode = Convert.ToString(HttpContext.Current.Request.RequestContext.RouteData.Values["url"]); sb.Append("<div id=\"Logo\">"); sb.Append("<a href=http://stackoverflow.com/"/\"><span id=\"Logo_Text\">Dr. Shreekumar</span></a> <span id=\"Logo_Sub_Text\">Obstetrician & Gynecologist</span>"); sb.Append("</div>"); sb.Append("<div id=\"Primary_Menu\">"); sb.Append("<ul>"); foreach (Page page in primaryPages) { if (page.PageCode != "Home") { Page currentPage = Db.Pages.SingleOrDefault(p => p.PageCode == pagecode); if (currentPage != null) { Page parentPage = Db.Pages.Find(currentPage.ParentId); if (parentPage != null) { sb.AppendFormat((page.PageCode == parentPage.PageCode || page.PageCode == currentPage.PageCode) ? "<li class=\"active\"><a href=http://stackoverflow.com/"/pages/{0}\">{1}</a></li>" : "<li><a href=http://stackoverflow.com/"/pages/{0}\">{1}</a></li>", page.PageCode, page.Name.Trim()); } else { sb.AppendFormat("<li><a href=http://stackoverflow.com/"/pages/{0}\">{1}</a></li>", page.PageCode,page.Name); } } else { sb.AppendFormat("<li><a href=http://stackoverflow.com/"/pages/{0}\">{1}</a></li>", page.PageCode, page.Name); } } } sb.Append("</ul>"); sb.Append("</div>"); return new MvcHtmlString(sb.ToString()); }\[/code\]Can anybody suggest me that how can I convert this using MVC HTML helpers (helpers for anchor, list (li), div etc)