Advertisement
Guest User

Untitled

a guest
Aug 4th, 2010
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.57 KB | None | 0 0
  1. Getting error: <code>Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
  2.  
  3. Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper<object>' does not contain a definition for 'Body' and no extension method 'Body' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<object>' could be found (are you missing a using directive or an assembly reference?)</code> on the <code>body</code> line   
  4.  
  5.     namespace MySite.Helpers
  6.     {
  7.         public static class HtmlHelpers
  8.         {
  9.             public static MvcHtmlString Body(this HtmlHelper htmlHelper)
  10.             {
  11.                 string currentControllerName = (string)htmlHelper.ViewContext.RouteData.Values["controller"];
  12.                 string currentActionName = (string)htmlHelper.ViewContext.RouteData.Values["action"];
  13.                 string css = currentControllerName + "-" + currentActionName;
  14.                 var body = new TagBuilder("body");
  15.                 body.AddCssClass(css);
  16.                 return MvcHtmlString.Create(body.ToString(TagRenderMode.StartTag));
  17.             }
  18.         }
  19.        
  20.     }
  21.  
  22. ~/Views/Shared/Site.Master:
  23.  
  24.     <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
  25.  
  26.     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  27.     <html xmlns="http://www.w3.org/1999/xhtml">
  28.     <head runat="server">
  29.         <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
  30.         <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
  31.     </head>
  32.  
  33.     <body id="argh" class="<%= Html.Body() %>">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement