A namespace cannot directly contain members such as fields or methods

Topics: ASP.NET MVC
Apr 1, 2012 at 7:13 AM

Hello,

I'm getting this error when I build the sln. I already do "Build RestorePackages" and run the Visual Studio with admin right. I tried to use build.cmd with admin right as well but I'm getting the same error. 

Error 1 A namespace cannot directly contain members such as fields or methods C:\Michael Sync\++ Project\aspnetwebstack\aspnetwebstack\src\System.Web.Helpers\WebGrid\_WebGridRenderer.generated.cs 1 1 System.Web.Helpers

Apr 1, 2012 at 7:38 AM

I got this "Cannot find custom tool 'RazorHelperGenerator' on this system." after deleting everything in _WebGridRenderer.generated.cs. Initially, I thought it's just a generated file so it will be generated when I save the file or re-build. but it doesn't so I looked for 'RazorHelperGenerator' in entire solution but I couldn't find any..

Am I missing something?

Apr 1, 2012 at 3:41 PM
Edited Apr 2, 2012 at 3:07 AM

One more information.. I have VS 2010 and VS 2011 on my machine. I couldn't able to compile nuget source (because of code analysis assembly) on machine that has both Vs10 and Vs11 installed. 

Edit: I tried on the machine that has only VS10 but I got the same error. 

Apr 1, 2012 at 6:59 PM

I have a similar problem. It looks like the generated code is broken. :/

Apr 2, 2012 at 2:13 AM

I had this problem.  Is it possible that you guys are using the beta version of GitHub for Windows?  When I used GitExtensions to pull the source, the problem went away.

Apr 2, 2012 at 2:55 AM

Thanks Darrel and Daniel.

Hi Darrel,

I will try with beta version but it's very strange if compiling the code is related to the version control.. 

Is it possible for you to send me your "working" _WebGridRenderer.generated.cs to my email "michael.sync AT gmail DOT com" ? 

Do you have RazorHelperGenerator tool installed? If yes, where can I download it or how can I register it? 

 

 

Apr 2, 2012 at 3:05 AM
DarrelMiller wrote:

I had this problem.  Is it possible that you guys are using the beta version of GitHub for Windows?  When I used GitExtensions to pull the source, the problem went away.

Hi Darrel,

Just to confirm. You mean, "beta version of Github" = "msysgit's Git-1.7.8-preview20111206.exe - Full installer for official Git for Windows 1.7.8  - Beta", right? 

Apr 2, 2012 at 3:48 AM

Just to update. I tested with Git-1.7.8-preview20111206.exe. I got the same error. I found that the generated one on my machine is different from the one on server. So, I copied it and will try building it again. 

Apr 2, 2012 at 3:53 AM

The Actual File looks like this. 

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.214
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.WebPages;

namespace System.Web.Helpers
{
    [GeneratedCode("RazorSingleFileGenerator", "1.0.0.0")]
    internal class WebGridRenderer : HelperPage
    {
#line hidden
#line hidden
        public static HelperResult GridInitScript(WebGrid webGrid, HttpContextBase httpContext)
        {
            return new HelperResult(__razor_helper_writer =>
            {
                if (!webGrid.IsAjaxEnabled)
                {
                    return;
                }
                if (!IsGridScriptRendered(httpContext))
                {
                    SetGridScriptRendered(httpContext, true);

                    WriteLiteralTo(@__razor_helper_writer, "        <script type=\"text/javascript\">\r\n        (function($) {\r\n            $.fn" +
                                                           ".swhgLoad = function(url, containerId, callback) {\r\n                url = url + " +
                                                           "(url.indexOf(\'?\') == -1 ? \'?\' : \'&\') + \'__swhg=\' + new Date().getTime();\r\n\r\n    " +
                                                           "            $(\'<div/>\').load(url + \' \' + containerId, function(data, status, xhr" +
                                                           ") {\r\n                    $(containerId).replaceWith($(this).html());\r\n          " +
                                                           "          if (typeof(callback) === \'function\') {\r\n                        callba" +
                                                           "ck.apply(this, arguments);\r\n                    }\r\n                });\r\n        " +
                                                           "        return this;\r\n            }\r\n\r\n            $(function() {\r\n             " +
                                                           "   $(\'table[data-swhgajax=\"true\"],span[data-swhgajax=\"true\"]\').each(function() {" +
                                                           "\r\n                    var self = $(this);\r\n                    var containerId =" +
                                                           " \'#\' + self.data(\'swhgcontainer\');\r\n                    var callback = getFuncti" +
                                                           "on(self.data(\'swhgcallback\'));\r\n\r\n                    $(containerId).parent().de" +
                                                           "legate(containerId + \' a[data-swhglnk=\"true\"]\', \'click\', function() {\r\n         " +
                                                           "               $(containerId).swhgLoad($(this).attr(\'href\'), containerId, callba" +
                                                           "ck);\r\n                        return false;\r\n                    });\r\n          " +
                                                           "      })\r\n            });\r\n\r\n            function getFunction(code, argNames) {\r" +
                                                           "\n                argNames = argNames || [];\r\n                var fn = window, pa" +
                                                           "rts = (code || \"\").split(\".\");\r\n                while (fn && parts.length) {\r\n  " +
                                                           "                  fn = fn[parts.shift()];\r\n                }\r\n                if" +
                                                           " (typeof (fn) === \"function\") {\r\n                    return fn;\r\n               " +
                                                           " }\r\n                argNames.push(code);\r\n                return Function.constr" +
                                                           "uctor.apply(null, argNames);\r\n            }\r\n        })(jQuery);\r\n        </scri" +
                                                           "pt>\r\n");
                }
            });
        }

#line hidden
        public static HelperResult Table(WebGrid webGrid,
                                         HttpContextBase httpContext,
                                         string tableStyle,
                                         string headerStyle,
                                         string footerStyle,
                                         string rowStyle,
                                         string alternatingRowStyle,
                                         string selectedRowStyle,
                                         string caption,
                                         bool displayHeader,
                                         bool fillEmptyRows,
                                         string emptyRowCellValue,
                                         IEnumerable<WebGridColumn> columns,
                                         IEnumerable<string> exclusions,
                                         Func<dynamic, object> footer,
                                         object htmlAttributes)
        {
            return new HelperResult(__razor_helper_writer =>
            {
                if (emptyRowCellValue == null)
                {
                    emptyRowCellValue = "&nbsp;";
                }

                WriteTo(@__razor_helper_writer, GridInitScript(webGrid, httpContext));

                var htmlAttributeDictionary = TypeHelper.ObjectToDictionary(htmlAttributes);
                if (webGrid.IsAjaxEnabled)
                {
                    htmlAttributeDictionary["data-swhgajax"] = "true";
                    htmlAttributeDictionary["data-swhgcontainer"] = webGrid.AjaxUpdateContainerId;
                    htmlAttributeDictionary["data-swhgcallback"] = webGrid.AjaxUpdateCallback;
                }

                WriteLiteralTo(@__razor_helper_writer, "    <table");

                WriteTo(@__razor_helper_writer, tableStyle.IsEmpty() ? null : Raw(" class=\"" + HttpUtility.HtmlAttributeEncode(tableStyle) + "\""));

                WriteTo(@__razor_helper_writer, PrintAttributes(htmlAttributeDictionary));

                WriteLiteralTo(@__razor_helper_writer, ">\r\n");

                if (!caption.IsEmpty())
                {
                    WriteLiteralTo(@__razor_helper_writer, "        <caption>");

                    WriteTo(@__razor_helper_writer, caption);

                    WriteLiteralTo(@__razor_helper_writer, "</caption>\r\n");
                }

                if (displayHeader)
                {
                    WriteLiteralTo(@__razor_helper_writer, "    <thead>\r\n        <tr");

                    WriteTo(@__razor_helper_writer, CssClass(headerStyle));

                    WriteLiteralTo(@__razor_helper_writer, ">\r\n");

                    foreach (var column in columns)
                    {
                        WriteLiteralTo(@__razor_helper_writer, "            <th scope=\"col\">\r\n");

                        if (ShowSortableColumnHeader(webGrid, column))
                        {
                            var text = column.Header.IsEmpty() ? column.ColumnName : column.Header;

                            WriteTo(@__razor_helper_writer, GridLink(webGrid, webGrid.GetSortUrl(column.ColumnName), text));
                        }
                        else
                        {
                            WriteTo(@__razor_helper_writer, column.Header ?? column.ColumnName);
                        }

                        WriteLiteralTo(@__razor_helper_writer, "            </th>\r\n");
                    }

                    WriteLiteralTo(@__razor_helper_writer, "        </tr>\r\n    </thead>\r\n");
                }

                if (footer != null)
                {
                    WriteLiteralTo(@__razor_helper_writer, "    <tfoot>\r\n        <tr ");

                    WriteTo(@__razor_helper_writer, CssClass(footerStyle));

                    WriteLiteralTo(@__razor_helper_writer, ">\r\n            <td colspan=\"");

                    WriteTo(@__razor_helper_writer, columns.Count());

                    WriteLiteralTo(@__razor_helper_writer, "\">");

                    WriteTo(@__razor_helper_writer, Format(footer, null));

                    WriteLiteralTo(@__razor_helper_writer, "</td>\r\n        </tr>\r\n    </tfoot>\r\n");
                }

                WriteLiteralTo(@__razor_helper_writer, "    <tbody>\r\n");

                int rowIndex = 0;

                foreach (var row in webGrid.Rows)
                {
                    string style = GetRowStyle(webGrid, rowIndex++, rowStyle, alternatingRowStyle, selectedRowStyle);

                    WriteLiteralTo(@__razor_helper_writer, "        <tr");

                    WriteTo(@__razor_helper_writer, CssClass(style));

                    WriteLiteralTo(@__razor_helper_writer, ">\r\n");

                    foreach (var column in columns)
                    {
                        var value = (column.Format == null) ? HttpUtility.HtmlEncode(row[column.ColumnName]) : Format(column.Format, row).ToString();

                        WriteLiteralTo(@__razor_helper_writer, "            <td");

                        WriteTo(@__razor_helper_writer, CssClass(column.Style));

                        WriteLiteralTo(@__razor_helper_writer, ">");

                        WriteTo(@__razor_helper_writer, Raw(value));

                        WriteLiteralTo(@__razor_helper_writer, "</td>\r\n");
                    }

                    WriteLiteralTo(@__razor_helper_writer, "        </tr>\r\n");
                }

                if (fillEmptyRows)
                {
                    rowIndex = webGrid.Rows.Count;
                    while (rowIndex < webGrid.RowsPerPage)
                    {
                        string style = GetRowStyle(webGrid, rowIndex++, rowStyle, alternatingRowStyle, null);

                        WriteLiteralTo(@__razor_helper_writer, "            <tr");

                        WriteTo(@__razor_helper_writer, CssClass(style));

                        WriteLiteralTo(@__razor_helper_writer, ">\r\n");

                        foreach (var column in columns)
                        {
                            WriteLiteralTo(@__razor_helper_writer, "                    <td");

                            WriteTo(@__razor_helper_writer, CssClass(column.Style));

                            WriteLiteralTo(@__razor_helper_writer, ">");

                            WriteTo(@__razor_helper_writer, Raw(emptyRowCellValue));

                            WriteLiteralTo(@__razor_helper_writer, "</td>\r\n");
                        }

                        WriteLiteralTo(@__razor_helper_writer, "            </tr>\r\n");
                    }
                }

                WriteLiteralTo(@__razor_helper_writer, "    </tbody>\r\n    </table>\r\n");
            });
        }

#line hidden
        public static HelperResult Pager(
            WebGrid webGrid,
            HttpContextBase httpContext,
            WebGridPagerModes mode,
            string firstText,
            string previousText,
            string nextText,
            string lastText,
            int numericLinksCount,
            bool renderAjaxContainer)
        {
            return new HelperResult(__razor_helper_writer =>
            {
                int currentPage = webGrid.PageIndex;
                int totalPages = webGrid.PageCount;
                int lastPage = totalPages - 1;

                WriteTo(@__razor_helper_writer, GridInitScript(webGrid, httpContext));

                if (renderAjaxContainer && webGrid.IsAjaxEnabled)
                {
                    WriteLiteralTo(@__razor_helper_writer, "        ");

                    WriteLiteralTo(@__razor_helper_writer, "<span data-swhgajax=\"true\" data-swhgcontainer=\"");

                    WriteTo(@__razor_helper_writer, webGrid.AjaxUpdateContainerId);

                    WriteLiteralTo(@__razor_helper_writer, "\" data-swhgcallback=\"");

                    WriteTo(@__razor_helper_writer, webGrid.AjaxUpdateCallback);

                    WriteLiteralTo(@__razor_helper_writer, "\">\r\n");
                }

                if (ModeEnabled(mode, WebGridPagerModes.FirstLast) && currentPage > 1)
                {
                    if (String.IsNullOrEmpty(firstText))
                    {
                        firstText = "<<";
                    }

                    WriteTo(@__razor_helper_writer, GridLink(webGrid, webGrid.GetPageUrl(0), firstText));

                    WriteTo(@__razor_helper_writer, Raw(" "));
                }

                if (ModeEnabled(mode, WebGridPagerModes.NextPrevious) && currentPage > 0)
                {
                    if (String.IsNullOrEmpty(previousText))
                    {
                        previousText = "<";
                    }

                    WriteTo(@__razor_helper_writer, GridLink(webGrid, webGrid.GetPageUrl(currentPage - 1), previousText));

                    WriteTo(@__razor_helper_writer, Raw(" "));
                }

                if (ModeEnabled(mode, WebGridPagerModes.Numeric) && (totalPages > 1))
                {
                    int last = currentPage + (numericLinksCount / 2);
                    int first = last - numericLinksCount + 1;
                    if (last > lastPage)
                    {
                        first -= last - lastPage;
                        last = lastPage;
                    }
                    if (first < 0)
                    {
                        last = Math.Min(last + (0 - first), lastPage);
                        first = 0;
                    }
                    for (int i = first; i <= last; i++)
                    {
                        var pageText = (i + 1).ToString(CultureInfo.InvariantCulture);
                        if (i == currentPage)
                        {
                            WriteTo(@__razor_helper_writer, pageText);
                        }
                        else
                        {
                            WriteTo(@__razor_helper_writer, GridLink(webGrid, webGrid.GetPageUrl(i), pageText));
                        }

                        WriteTo(@__razor_helper_writer, Raw(" "));
                    }
                }

                if (ModeEnabled(mode, WebGridPagerModes.NextPrevious) && (currentPage < lastPage))
                {
                    if (String.IsNullOrEmpty(nextText))
                    {
                        nextText = ">";
                    }

                    WriteTo(@__razor_helper_writer, GridLink(webGrid, webGrid.GetPageUrl(currentPage + 1), nextText));

                    WriteTo(@__razor_helper_writer, Raw(" "));
                }

                if (ModeEnabled(mode, WebGridPagerModes.FirstLast) && (currentPage < lastPage - 1))
                {
                    if (String.IsNullOrEmpty(lastText))
                    {
                        lastText = ">>";
                    }

                    WriteTo(@__razor_helper_writer, GridLink(webGrid, webGrid.GetPageUrl(lastPage), lastText));
                }

                if (renderAjaxContainer && webGrid.IsAjaxEnabled)
                {
                    WriteLiteralTo(@__razor_helper_writer, "        ");

                    WriteLiteralTo(@__razor_helper_writer, "</span>\r\n");
                }
            });
        }

        private static readonly object _gridScriptRenderedKey = new object();

        private static bool IsGridScriptRendered(HttpContextBase context)
        {
            bool? value = (bool?)context.Items[_gridScriptRenderedKey];
            return value.HasValue && value.Value;
        }

        private static void SetGridScriptRendered(HttpContextBase context, bool value)
        {
            context.Items[_gridScriptRenderedKey] = value;
        }

        private static bool ShowSortableColumnHeader(WebGrid grid, WebGridColumn column)
        {
            return grid.CanSort && column.CanSort && !column.ColumnName.IsEmpty();
        }

        public static IHtmlString GridLink(WebGrid webGrid, string url, string text)
        {
            TagBuilder builder = new TagBuilder("a");
            builder.SetInnerText(text);
            builder.MergeAttribute("href", url);
            if (webGrid.IsAjaxEnabled)
            {
                builder.MergeAttribute("data-swhglnk", "true");
            }
            return builder.ToHtmlString(TagRenderMode.Normal);
        }

        private static IHtmlString Raw(string text)
        {
            return new HtmlString(text);
        }

        private static IHtmlString RawJS(string text)
        {
            return new HtmlString(HttpUtility.JavaScriptStringEncode(text));
        }

        private static IHtmlString CssClass(string className)
        {
            return new HtmlString((!className.IsEmpty()) ? " class=\"" + HttpUtility.HtmlAttributeEncode(className) + "\"" : String.Empty);
        }

        private static string GetRowStyle(WebGrid webGrid, int rowIndex, string rowStyle, string alternatingRowStyle, string selectedRowStyle)
        {
            StringBuilder style = new StringBuilder();

            if (rowIndex % 2 == 0)
            {
                if (!String.IsNullOrEmpty(rowStyle))
                {
                    style.Append(rowStyle);
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(alternatingRowStyle))
                {
                    style.Append(alternatingRowStyle);
                }
            }

            if (!String.IsNullOrEmpty(selectedRowStyle) && (rowIndex == webGrid.SelectedIndex))
            {
                if (style.Length > 0)
                {
                    style.Append(" ");
                }
                style.Append(selectedRowStyle);
            }
            return style.ToString();
        }

        private static HelperResult Format(Func<dynamic, object> format, dynamic arg)
        {
            var result = format(arg);
            return new HelperResult(tw =>
            {
                var helper = result as HelperResult;
                if (helper != null)
                {
                    helper.WriteTo(tw);
                    return;
                }
                IHtmlString htmlString = result as IHtmlString;
                if (htmlString != null)
                {
                    tw.Write(htmlString);
                    return;
                }
                if (result != null)
                {
                    tw.Write(HttpUtility.HtmlEncode(result));
                }
            });
        }

        private static IHtmlString PrintAttributes(IDictionary<string, object> attributes)
        {
            var builder = new StringBuilder();
            foreach (var item in attributes)
            {
                var value = Convert.ToString(item.Value, CultureInfo.InvariantCulture);
                builder.Append(' ')
                    .Append(HttpUtility.HtmlEncode(item.Key))
                    .Append("=\"")
                    .Append(HttpUtility.HtmlAttributeEncode(value))
                    .Append('"');
            }
            return new HtmlString(builder.ToString());
        }

        private static bool ModeEnabled(WebGridPagerModes mode, WebGridPagerModes modeCheck)
        {
            return (mode & modeCheck) == modeCheck;
        }

        protected static HttpApplication ApplicationInstance
        {
            get { return ((Context.ApplicationInstance)); }
        }
    }
}

 

The one that I downloaded or cloned

//------------------------------------------------------------------------------਍⼀⼀ 㰀愀甀琀漀ⴀ最攀渀攀爀愀琀攀搀㸀ഀഀ//     This code was generated by a tool.਍⼀⼀     刀甀渀琀椀洀攀 嘀攀爀猀椀漀渀㨀㐀⸀ ⸀㌀ ㌀㄀㤀⸀㈀㄀㐀ഀഀ//਍⼀⼀     䌀栀愀渀最攀猀 琀漀 琀栀椀猀 昀椀氀攀 洀愀礀 挀愀甀猀攀 椀渀挀漀爀爀攀挀琀 戀攀栀愀瘀椀漀爀 愀渀搀 眀椀氀氀 戀攀 氀漀猀琀 椀昀ഀഀ//     the code is regenerated.਍⼀⼀ 㰀⼀愀甀琀漀ⴀ最攀渀攀爀愀琀攀搀㸀ഀഀ//------------------------------------------------------------------------------਍ഀഀusing System.CodeDom.Compiler;਍甀猀椀渀最 匀礀猀琀攀洀⸀䌀漀氀氀攀挀琀椀漀渀猀⸀䜀攀渀攀爀椀挀㬀ഀഀusing System.Globalization;਍甀猀椀渀最 匀礀猀琀攀洀⸀䰀椀渀焀㬀ഀഀusing System.Text;਍甀猀椀渀最 匀礀猀琀攀洀⸀圀攀戀⸀䴀瘀挀㬀ഀഀusing System.Web.WebPages;਍ഀഀnamespace System.Web.Helpers਍笀ഀഀ    [GeneratedCode("RazorSingleFileGenerator", "1.0.0.0")]਍    椀渀琀攀爀渀愀氀 挀氀愀猀猀 圀攀戀䜀爀椀搀刀攀渀搀攀爀攀爀 㨀 䠀攀氀瀀攀爀倀愀最攀ഀഀ    {਍⌀氀椀渀攀 栀椀搀搀攀渀ഀഀ#line hidden਍        瀀甀戀氀椀挀 猀琀愀琀椀挀 䠀攀氀瀀攀爀刀攀猀甀氀琀 䜀爀椀搀䤀渀椀琀匀挀爀椀瀀琀⠀圀攀戀䜀爀椀搀 眀攀戀䜀爀椀搀Ⰰ 䠀琀琀瀀䌀漀渀琀攀砀琀䈀愀猀攀 栀琀琀瀀䌀漀渀琀攀砀琀⤀ഀഀ        {਍            爀攀琀甀爀渀 渀攀眀 䠀攀氀瀀攀爀刀攀猀甀氀琀⠀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀 㴀㸀ഀഀ            {਍                椀昀 ⠀℀眀攀戀䜀爀椀搀⸀䤀猀䄀樀愀砀䔀渀愀戀氀攀搀⤀ഀഀ                {਍                    爀攀琀甀爀渀㬀ഀഀ                }਍                椀昀 ⠀℀䤀猀䜀爀椀搀匀挀爀椀瀀琀刀攀渀搀攀爀攀搀⠀栀琀琀瀀䌀漀渀琀攀砀琀⤀⤀ഀഀ                {਍                    匀攀琀䜀爀椀搀匀挀爀椀瀀琀刀攀渀搀攀爀攀搀⠀栀琀琀瀀䌀漀渀琀攀砀琀Ⰰ 琀爀甀攀⤀㬀ഀഀ
਍                    圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀        㰀猀挀爀椀瀀琀 琀礀瀀攀㴀尀∀琀攀砀琀⼀樀愀瘀愀猀挀爀椀瀀琀尀∀㸀尀爀尀渀        ⠀昀甀渀挀琀椀漀渀⠀␀⤀ 笀尀爀尀渀            ␀⸀昀渀∀ ⬀ഀഀ                                                           ".swhgLoad = function(url, containerId, callback) {\r\n                url = url + " +਍                                                           ∀⠀甀爀氀⸀椀渀搀攀砀伀昀⠀尀✀㼀尀✀⤀ 㴀㴀 ⴀ㄀ 㼀 尀✀㼀尀✀ 㨀 尀✀☀尀✀⤀ ⬀ 尀✀开开猀眀栀最㴀尀✀ ⬀ 渀攀眀 䐀愀琀攀⠀⤀⸀最攀琀吀椀洀攀⠀⤀㬀尀爀尀渀尀爀尀渀    ∀ ⬀ഀഀ                                                           "            $(\'<div/>\').load(url + \' \' + containerId, function(data, status, xhr" +਍                                                           ∀⤀ 笀尀爀尀渀                    ␀⠀挀漀渀琀愀椀渀攀爀䤀搀⤀⸀爀攀瀀氀愀挀攀圀椀琀栀⠀␀⠀琀栀椀猀⤀⸀栀琀洀氀⠀⤀⤀㬀尀爀尀渀          ∀ ⬀ഀഀ                                                           "          if (typeof(callback) === \'function\') {\r\n                        callba" +਍                                                           ∀挀欀⸀愀瀀瀀氀礀⠀琀栀椀猀Ⰰ 愀爀最甀洀攀渀琀猀⤀㬀尀爀尀渀                    紀尀爀尀渀                紀⤀㬀尀爀尀渀        ∀ ⬀ഀഀ                                                           "        return this;\r\n            }\r\n\r\n            $(function() {\r\n             " +਍                                                           ∀   ␀⠀尀✀琀愀戀氀攀嬀搀愀琀愀ⴀ猀眀栀最愀樀愀砀㴀尀∀琀爀甀攀尀∀崀Ⰰ猀瀀愀渀嬀搀愀琀愀ⴀ猀眀栀最愀樀愀砀㴀尀∀琀爀甀攀尀∀崀尀✀⤀⸀攀愀挀栀⠀昀甀渀挀琀椀漀渀⠀⤀ 笀∀ ⬀ഀഀ                                                           "\r\n                    var self = $(this);\r\n                    var containerId =" +਍                                                           ∀ 尀✀⌀尀✀ ⬀ 猀攀氀昀⸀搀愀琀愀⠀尀✀猀眀栀最挀漀渀琀愀椀渀攀爀尀✀⤀㬀尀爀尀渀                    瘀愀爀 挀愀氀氀戀愀挀欀 㴀 最攀琀䘀甀渀挀琀椀∀ ⬀ഀഀ                                                           "on(self.data(\'swhgcallback\'));\r\n\r\n                    $(containerId).parent().de" +਍                                                           ∀氀攀最愀琀攀⠀挀漀渀琀愀椀渀攀爀䤀搀 ⬀ 尀✀ 愀嬀搀愀琀愀ⴀ猀眀栀最氀渀欀㴀尀∀琀爀甀攀尀∀崀尀✀Ⰰ 尀✀挀氀椀挀欀尀✀Ⰰ 昀甀渀挀琀椀漀渀⠀⤀ 笀尀爀尀渀         ∀ ⬀ഀഀ                                                           "               $(containerId).swhgLoad($(this).attr(\'href\'), containerId, callba" +਍                                                           ∀挀欀⤀㬀尀爀尀渀                        爀攀琀甀爀渀 昀愀氀猀攀㬀尀爀尀渀                    紀⤀㬀尀爀尀渀          ∀ ⬀ഀഀ                                                           "      })\r\n            });\r\n\r\n            function getFunction(code, argNames) {\r" +਍                                                           ∀尀渀                愀爀最一愀洀攀猀 㴀 愀爀最一愀洀攀猀 簀簀 嬀崀㬀尀爀尀渀                瘀愀爀 昀渀 㴀 眀椀渀搀漀眀Ⰰ 瀀愀∀ ⬀ഀഀ                                                           "rts = (code || \"\").split(\".\");\r\n                while (fn && parts.length) {\r\n  " +਍                                                           ∀                  昀渀 㴀 昀渀嬀瀀愀爀琀猀⸀猀栀椀昀琀⠀⤀崀㬀尀爀尀渀                紀尀爀尀渀                椀昀∀ ⬀ഀഀ                                                           " (typeof (fn) === \"function\") {\r\n                    return fn;\r\n               " +਍                                                           ∀ 紀尀爀尀渀                愀爀最一愀洀攀猀⸀瀀甀猀栀⠀挀漀搀攀⤀㬀尀爀尀渀                爀攀琀甀爀渀 䘀甀渀挀琀椀漀渀⸀挀漀渀猀琀爀∀ ⬀ഀഀ                                                           "uctor.apply(null, argNames);\r\n            }\r\n        })(jQuery);\r\n        </scri" +਍                                                           ∀瀀琀㸀尀爀尀渀∀⤀㬀ഀഀ                }਍            紀⤀㬀ഀഀ        }਍ഀഀ#line hidden਍        瀀甀戀氀椀挀 猀琀愀琀椀挀 䠀攀氀瀀攀爀刀攀猀甀氀琀 吀愀戀氀攀⠀圀攀戀䜀爀椀搀 眀攀戀䜀爀椀搀Ⰰഀഀ                                         HttpContextBase httpContext,਍                                         猀琀爀椀渀最 琀愀戀氀攀匀琀礀氀攀Ⰰഀഀ                                         string headerStyle,਍                                         猀琀爀椀渀最 昀漀漀琀攀爀匀琀礀氀攀Ⰰഀഀ                                         string rowStyle,਍                                         猀琀爀椀渀最 愀氀琀攀爀渀愀琀椀渀最刀漀眀匀琀礀氀攀Ⰰഀഀ                                         string selectedRowStyle,਍                                         猀琀爀椀渀最 挀愀瀀琀椀漀渀Ⰰഀഀ                                         bool displayHeader,਍                                         戀漀漀氀 昀椀氀氀䔀洀瀀琀礀刀漀眀猀Ⰰഀഀ                                         string emptyRowCellValue,਍                                         䤀䔀渀甀洀攀爀愀戀氀攀㰀圀攀戀䜀爀椀搀䌀漀氀甀洀渀㸀 挀漀氀甀洀渀猀Ⰰഀഀ                                         IEnumerable<string> exclusions,਍                                         䘀甀渀挀㰀搀礀渀愀洀椀挀Ⰰ 漀戀樀攀挀琀㸀 昀漀漀琀攀爀Ⰰഀഀ                                         object htmlAttributes)਍        笀ഀഀ            return new HelperResult(__razor_helper_writer =>਍            笀ഀഀ                if (emptyRowCellValue == null)਍                笀ഀഀ                    emptyRowCellValue = "&nbsp;";਍                紀ഀഀ
਍                圀爀椀琀攀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ 䜀爀椀搀䤀渀椀琀匀挀爀椀瀀琀⠀眀攀戀䜀爀椀搀Ⰰ 栀琀琀瀀䌀漀渀琀攀砀琀⤀⤀㬀ഀഀ
਍                瘀愀爀 栀琀洀氀䄀琀琀爀椀戀甀琀攀䐀椀挀琀椀漀渀愀爀礀 㴀 吀礀瀀攀䠀攀氀瀀攀爀⸀伀戀樀攀挀琀吀漀䐀椀挀琀椀漀渀愀爀礀⠀栀琀洀氀䄀琀琀爀椀戀甀琀攀猀⤀㬀ഀഀ                if (webGrid.IsAjaxEnabled)਍                笀ഀഀ                    htmlAttributeDictionary["data-swhgajax"] = "true";਍                    栀琀洀氀䄀琀琀爀椀戀甀琀攀䐀椀挀琀椀漀渀愀爀礀嬀∀搀愀琀愀ⴀ猀眀栀最挀漀渀琀愀椀渀攀爀∀崀 㴀 眀攀戀䜀爀椀搀⸀䄀樀愀砀唀瀀搀愀琀攀䌀漀渀琀愀椀渀攀爀䤀搀㬀ഀഀ                    htmlAttributeDictionary["data-swhgcallback"] = webGrid.AjaxUpdateCallback;਍                紀ഀഀ
਍                圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀    㰀琀愀戀氀攀∀⤀㬀ഀഀ
਍                圀爀椀琀攀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ 琀愀戀氀攀匀琀礀氀攀⸀䤀猀䔀洀瀀琀礀⠀⤀ 㼀 渀甀氀氀 㨀 刀愀眀⠀∀ 挀氀愀猀猀㴀尀∀∀ ⬀ 䠀琀琀瀀唀琀椀氀椀琀礀⸀䠀琀洀氀䄀琀琀爀椀戀甀琀攀䔀渀挀漀搀攀⠀琀愀戀氀攀匀琀礀氀攀⤀ ⬀ ∀尀∀∀⤀⤀㬀ഀഀ
਍                圀爀椀琀攀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ 倀爀椀渀琀䄀琀琀爀椀戀甀琀攀猀⠀栀琀洀氀䄀琀琀爀椀戀甀琀攀䐀椀挀琀椀漀渀愀爀礀⤀⤀㬀ഀഀ
਍                圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀㸀尀爀尀渀∀⤀㬀ഀഀ
਍                椀昀 ⠀℀挀愀瀀琀椀漀渀⸀䤀猀䔀洀瀀琀礀⠀⤀⤀ഀഀ                {਍                    圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀        㰀挀愀瀀琀椀漀渀㸀∀⤀㬀ഀഀ
਍                    圀爀椀琀攀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ 挀愀瀀琀椀漀渀⤀㬀ഀഀ
਍                    圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀㰀⼀挀愀瀀琀椀漀渀㸀尀爀尀渀∀⤀㬀ഀഀ                }਍ഀഀ                if (displayHeader)਍                笀ഀഀ                    WriteLiteralTo(@__razor_helper_writer, "    <thead>\r\n        <tr");਍ഀഀ                    WriteTo(@__razor_helper_writer, CssClass(headerStyle));਍ഀഀ                    WriteLiteralTo(@__razor_helper_writer, ">\r\n");਍ഀഀ                    foreach (var column in columns)਍                    笀ഀഀ                        WriteLiteralTo(@__razor_helper_writer, "            <th scope=\"col\">\r\n");਍ഀഀ                        if (ShowSortableColumnHeader(webGrid, column))਍                        笀ഀഀ                            var text = column.Header.IsEmpty() ? column.ColumnName : column.Header;਍ഀഀ                            WriteTo(@__razor_helper_writer, GridLink(webGrid, webGrid.GetSortUrl(column.ColumnName), text));਍                        紀ഀഀ                        else਍                        笀ഀഀ                            WriteTo(@__razor_helper_writer, column.Header ?? column.ColumnName);਍                        紀ഀഀ
਍                        圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀            㰀⼀琀栀㸀尀爀尀渀∀⤀㬀ഀഀ                    }਍ഀഀ                    WriteLiteralTo(@__razor_helper_writer, "        </tr>\r\n    </thead>\r\n");਍                紀ഀഀ
਍                椀昀 ⠀昀漀漀琀攀爀 ℀㴀 渀甀氀氀⤀ഀഀ                {਍                    圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀    㰀琀昀漀漀琀㸀尀爀尀渀        㰀琀爀 ∀⤀㬀ഀഀ
਍                    圀爀椀琀攀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ 䌀猀猀䌀氀愀猀猀⠀昀漀漀琀攀爀匀琀礀氀攀⤀⤀㬀ഀഀ
਍                    圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀㸀尀爀尀渀            㰀琀搀 挀漀氀猀瀀愀渀㴀尀∀∀⤀㬀ഀഀ
਍                    圀爀椀琀攀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ 挀漀氀甀洀渀猀⸀䌀漀甀渀琀⠀⤀⤀㬀ഀഀ
਍                    圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀尀∀㸀∀⤀㬀ഀഀ
਍                    圀爀椀琀攀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ 䘀漀爀洀愀琀⠀昀漀漀琀攀爀Ⰰ 渀甀氀氀⤀⤀㬀ഀഀ
਍                    圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀㰀⼀琀搀㸀尀爀尀渀        㰀⼀琀爀㸀尀爀尀渀    㰀⼀琀昀漀漀琀㸀尀爀尀渀∀⤀㬀ഀഀ                }਍ഀഀ                WriteLiteralTo(@__razor_helper_writer, "    <tbody>\r\n");਍ഀഀ                int rowIndex = 0;਍ഀഀ                foreach (var row in webGrid.Rows)਍                笀ഀഀ                    string style = GetRowStyle(webGrid, rowIndex++, rowStyle, alternatingRowStyle, selectedRowStyle);਍ഀഀ                    WriteLiteralTo(@__razor_helper_writer, "        <tr");਍ഀഀ                    WriteTo(@__razor_helper_writer, CssClass(style));਍ഀഀ                    WriteLiteralTo(@__razor_helper_writer, ">\r\n");਍ഀഀ                    foreach (var column in columns)਍                    笀ഀഀ                        var value = (column.Format == null) ? HttpUtility.HtmlEncode(row[column.ColumnName]) : Format(column.Format, row).ToString();਍ഀഀ                        WriteLiteralTo(@__razor_helper_writer, "            <td");਍ഀഀ                        WriteTo(@__razor_helper_writer, CssClass(column.Style));਍ഀഀ                        WriteLiteralTo(@__razor_helper_writer, ">");਍ഀഀ                        WriteTo(@__razor_helper_writer, Raw(value));਍ഀഀ                        WriteLiteralTo(@__razor_helper_writer, "</td>\r\n");਍                    紀ഀഀ
਍                    圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀        㰀⼀琀爀㸀尀爀尀渀∀⤀㬀ഀഀ                }਍ഀഀ                if (fillEmptyRows)਍                笀ഀഀ                    rowIndex = webGrid.Rows.Count;਍                    眀栀椀氀攀 ⠀爀漀眀䤀渀搀攀砀 㰀 眀攀戀䜀爀椀搀⸀刀漀眀猀倀攀爀倀愀最攀⤀ഀഀ                    {਍                        猀琀爀椀渀最 猀琀礀氀攀 㴀 䜀攀琀刀漀眀匀琀礀氀攀⠀眀攀戀䜀爀椀搀Ⰰ 爀漀眀䤀渀搀攀砀⬀⬀Ⰰ 爀漀眀匀琀礀氀攀Ⰰ 愀氀琀攀爀渀愀琀椀渀最刀漀眀匀琀礀氀攀Ⰰ 渀甀氀氀⤀㬀ഀഀ
਍                        圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀            㰀琀爀∀⤀㬀ഀഀ
਍                        圀爀椀琀攀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ 䌀猀猀䌀氀愀猀猀⠀猀琀礀氀攀⤀⤀㬀ഀഀ
਍                        圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀㸀尀爀尀渀∀⤀㬀ഀഀ
਍                        昀漀爀攀愀挀栀 ⠀瘀愀爀 挀漀氀甀洀渀 椀渀 挀漀氀甀洀渀猀⤀ഀഀ                        {਍                            圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀                    㰀琀搀∀⤀㬀ഀഀ
਍                            圀爀椀琀攀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ 䌀猀猀䌀氀愀猀猀⠀挀漀氀甀洀渀⸀匀琀礀氀攀⤀⤀㬀ഀഀ
਍                            圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀㸀∀⤀㬀ഀഀ
਍                            圀爀椀琀攀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ 刀愀眀⠀攀洀瀀琀礀刀漀眀䌀攀氀氀嘀愀氀甀攀⤀⤀㬀ഀഀ
਍                            圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀㰀⼀琀搀㸀尀爀尀渀∀⤀㬀ഀഀ                        }਍ഀഀ                        WriteLiteralTo(@__razor_helper_writer, "            </tr>\r\n");਍                    紀ഀഀ                }਍ഀഀ                WriteLiteralTo(@__razor_helper_writer, "    </tbody>\r\n    </table>\r\n");਍            紀⤀㬀ഀഀ        }਍ഀഀ#line hidden਍        瀀甀戀氀椀挀 猀琀愀琀椀挀 䠀攀氀瀀攀爀刀攀猀甀氀琀 倀愀最攀爀⠀ഀഀ            WebGrid webGrid,਍            䠀琀琀瀀䌀漀渀琀攀砀琀䈀愀猀攀 栀琀琀瀀䌀漀渀琀攀砀琀Ⰰഀഀ            WebGridPagerModes mode,਍            猀琀爀椀渀最 昀椀爀猀琀吀攀砀琀Ⰰഀഀ            string previousText,਍            猀琀爀椀渀最 渀攀砀琀吀攀砀琀Ⰰഀഀ            string lastText,਍            椀渀琀 渀甀洀攀爀椀挀䰀椀渀欀猀䌀漀甀渀琀Ⰰഀഀ            bool renderAjaxContainer)਍        笀ഀഀ            return new HelperResult(__razor_helper_writer =>਍            笀ഀഀ                int currentPage = webGrid.PageIndex;਍                椀渀琀 琀漀琀愀氀倀愀最攀猀 㴀 眀攀戀䜀爀椀搀⸀倀愀最攀䌀漀甀渀琀㬀ഀഀ                int lastPage = totalPages - 1;਍ഀഀ                WriteTo(@__razor_helper_writer, GridInitScript(webGrid, httpContext));਍ഀഀ                if (renderAjaxContainer && webGrid.IsAjaxEnabled)਍                笀ഀഀ                    WriteLiteralTo(@__razor_helper_writer, "        ");਍ഀഀ                    WriteLiteralTo(@__razor_helper_writer, "<span data-swhgajax=\"true\" data-swhgcontainer=\"");਍ഀഀ                    WriteTo(@__razor_helper_writer, webGrid.AjaxUpdateContainerId);਍ഀഀ                    WriteLiteralTo(@__razor_helper_writer, "\" data-swhgcallback=\"");਍ഀഀ                    WriteTo(@__razor_helper_writer, webGrid.AjaxUpdateCallback);਍ഀഀ                    WriteLiteralTo(@__razor_helper_writer, "\">\r\n");਍                紀ഀഀ
਍                椀昀 ⠀䴀漀搀攀䔀渀愀戀氀攀搀⠀洀漀搀攀Ⰰ 圀攀戀䜀爀椀搀倀愀最攀爀䴀漀搀攀猀⸀䘀椀爀猀琀䰀愀猀琀⤀ ☀☀ 挀甀爀爀攀渀琀倀愀最攀 㸀 ㄀⤀ഀഀ                {਍                    椀昀 ⠀匀琀爀椀渀最⸀䤀猀一甀氀氀伀爀䔀洀瀀琀礀⠀昀椀爀猀琀吀攀砀琀⤀⤀ഀഀ                    {਍                        昀椀爀猀琀吀攀砀琀 㴀 ∀㰀㰀∀㬀ഀഀ                    }਍ഀഀ                    WriteTo(@__razor_helper_writer, GridLink(webGrid, webGrid.GetPageUrl(0), firstText));਍ഀഀ                    WriteTo(@__razor_helper_writer, Raw(" "));਍                紀ഀഀ
਍                椀昀 ⠀䴀漀搀攀䔀渀愀戀氀攀搀⠀洀漀搀攀Ⰰ 圀攀戀䜀爀椀搀倀愀最攀爀䴀漀搀攀猀⸀一攀砀琀倀爀攀瘀椀漀甀猀⤀ ☀☀ 挀甀爀爀攀渀琀倀愀最攀 㸀  ⤀ഀഀ                {਍                    椀昀 ⠀匀琀爀椀渀最⸀䤀猀一甀氀氀伀爀䔀洀瀀琀礀⠀瀀爀攀瘀椀漀甀猀吀攀砀琀⤀⤀ഀഀ                    {਍                        瀀爀攀瘀椀漀甀猀吀攀砀琀 㴀 ∀㰀∀㬀ഀഀ                    }਍ഀഀ                    WriteTo(@__razor_helper_writer, GridLink(webGrid, webGrid.GetPageUrl(currentPage - 1), previousText));਍ഀഀ                    WriteTo(@__razor_helper_writer, Raw(" "));਍                紀ഀഀ
਍                椀昀 ⠀䴀漀搀攀䔀渀愀戀氀攀搀⠀洀漀搀攀Ⰰ 圀攀戀䜀爀椀搀倀愀最攀爀䴀漀搀攀猀⸀一甀洀攀爀椀挀⤀ ☀☀ ⠀琀漀琀愀氀倀愀最攀猀 㸀 ㄀⤀⤀ഀഀ                {਍                    椀渀琀 氀愀猀琀 㴀 挀甀爀爀攀渀琀倀愀最攀 ⬀ ⠀渀甀洀攀爀椀挀䰀椀渀欀猀䌀漀甀渀琀 ⼀ ㈀⤀㬀ഀഀ                    int first = last - numericLinksCount + 1;਍                    椀昀 ⠀氀愀猀琀 㸀 氀愀猀琀倀愀最攀⤀ഀഀ                    {਍                        昀椀爀猀琀 ⴀ㴀 氀愀猀琀 ⴀ 氀愀猀琀倀愀最攀㬀ഀഀ                        last = lastPage;਍                    紀ഀഀ                    if (first < 0)਍                    笀ഀഀ                        last = Math.Min(last + (0 - first), lastPage);਍                        昀椀爀猀琀 㴀  㬀ഀഀ                    }਍                    昀漀爀 ⠀椀渀琀 椀 㴀 昀椀爀猀琀㬀 椀 㰀㴀 氀愀猀琀㬀 椀⬀⬀⤀ഀഀ                    {਍                        瘀愀爀 瀀愀最攀吀攀砀琀 㴀 ⠀椀 ⬀ ㄀⤀⸀吀漀匀琀爀椀渀最⠀䌀甀氀琀甀爀攀䤀渀昀漀⸀䤀渀瘀愀爀椀愀渀琀䌀甀氀琀甀爀攀⤀㬀ഀഀ                        if (i == currentPage)਍                        笀ഀഀ                            WriteTo(@__razor_helper_writer, pageText);਍                        紀ഀഀ                        else਍                        笀ഀഀ                            WriteTo(@__razor_helper_writer, GridLink(webGrid, webGrid.GetPageUrl(i), pageText));਍                        紀ഀഀ
਍                        圀爀椀琀攀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ 刀愀眀⠀∀ ∀⤀⤀㬀ഀഀ                    }਍                紀ഀഀ
਍                椀昀 ⠀䴀漀搀攀䔀渀愀戀氀攀搀⠀洀漀搀攀Ⰰ 圀攀戀䜀爀椀搀倀愀最攀爀䴀漀搀攀猀⸀一攀砀琀倀爀攀瘀椀漀甀猀⤀ ☀☀ ⠀挀甀爀爀攀渀琀倀愀最攀 㰀 氀愀猀琀倀愀最攀⤀⤀ഀഀ                {਍                    椀昀 ⠀匀琀爀椀渀最⸀䤀猀一甀氀氀伀爀䔀洀瀀琀礀⠀渀攀砀琀吀攀砀琀⤀⤀ഀഀ                    {਍                        渀攀砀琀吀攀砀琀 㴀 ∀㸀∀㬀ഀഀ                    }਍ഀഀ                    WriteTo(@__razor_helper_writer, GridLink(webGrid, webGrid.GetPageUrl(currentPage + 1), nextText));਍ഀഀ                    WriteTo(@__razor_helper_writer, Raw(" "));਍                紀ഀഀ
਍                椀昀 ⠀䴀漀搀攀䔀渀愀戀氀攀搀⠀洀漀搀攀Ⰰ 圀攀戀䜀爀椀搀倀愀最攀爀䴀漀搀攀猀⸀䘀椀爀猀琀䰀愀猀琀⤀ ☀☀ ⠀挀甀爀爀攀渀琀倀愀最攀 㰀 氀愀猀琀倀愀最攀 ⴀ ㄀⤀⤀ഀഀ                {਍                    椀昀 ⠀匀琀爀椀渀最⸀䤀猀一甀氀氀伀爀䔀洀瀀琀礀⠀氀愀猀琀吀攀砀琀⤀⤀ഀഀ                    {਍                        氀愀猀琀吀攀砀琀 㴀 ∀㸀㸀∀㬀ഀഀ                    }਍ഀഀ                    WriteTo(@__razor_helper_writer, GridLink(webGrid, webGrid.GetPageUrl(lastPage), lastText));਍                紀ഀഀ
਍                椀昀 ⠀爀攀渀搀攀爀䄀樀愀砀䌀漀渀琀愀椀渀攀爀 ☀☀ 眀攀戀䜀爀椀搀⸀䤀猀䄀樀愀砀䔀渀愀戀氀攀搀⤀ഀഀ                {਍                    圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀        ∀⤀㬀ഀഀ
਍                    圀爀椀琀攀䰀椀琀攀爀愀氀吀漀⠀䀀开开爀愀稀漀爀开栀攀氀瀀攀爀开眀爀椀琀攀爀Ⰰ ∀㰀⼀猀瀀愀渀㸀尀爀尀渀∀⤀㬀ഀഀ                }਍            紀⤀㬀ഀഀ        }਍ഀഀ        private static readonly object _gridScriptRenderedKey = new object();਍ഀഀ        private static bool IsGridScriptRendered(HttpContextBase context)਍        笀ഀഀ            bool? value = (bool?)context.Items[_gridScriptRenderedKey];਍            爀攀琀甀爀渀 瘀愀氀甀攀⸀䠀愀猀嘀愀氀甀攀 ☀☀ 瘀愀氀甀攀⸀嘀愀氀甀攀㬀ഀഀ        }਍ഀഀ        private static void SetGridScriptRendered(HttpContextBase context, bool value)਍        笀ഀഀ            context.Items[_gridScriptRenderedKey] = value;਍        紀ഀഀ
਍        瀀爀椀瘀愀琀攀 猀琀愀琀椀挀 戀漀漀氀 匀栀漀眀匀漀爀琀愀戀氀攀䌀漀氀甀洀渀䠀攀愀搀攀爀⠀圀攀戀䜀爀椀搀 最爀椀搀Ⰰ 圀攀戀䜀爀椀搀䌀漀氀甀洀渀 挀漀氀甀洀渀⤀ഀഀ        {਍            爀攀琀甀爀渀 最爀椀搀⸀䌀愀渀匀漀爀琀 ☀☀ 挀漀氀甀洀渀⸀䌀愀渀匀漀爀琀 ☀☀ ℀挀漀氀甀洀渀⸀䌀漀氀甀洀渀一愀洀攀⸀䤀猀䔀洀瀀琀礀⠀⤀㬀ഀഀ        }਍ഀഀ        public static IHtmlString GridLink(WebGrid webGrid, string url, string text)਍        笀ഀഀ            TagBuilder builder = new TagBuilder("a");਍            戀甀椀氀搀攀爀⸀匀攀琀䤀渀渀攀爀吀攀砀琀⠀琀攀砀琀⤀㬀ഀഀ            builder.MergeAttribute("href", url);਍            椀昀 ⠀眀攀戀䜀爀椀搀⸀䤀猀䄀樀愀砀䔀渀愀戀氀攀搀⤀ഀഀ            {਍                戀甀椀氀搀攀爀⸀䴀攀爀最攀䄀琀琀爀椀戀甀琀攀⠀∀搀愀琀愀ⴀ猀眀栀最氀渀欀∀Ⰰ ∀琀爀甀攀∀⤀㬀ഀഀ            }਍            爀攀琀甀爀渀 戀甀椀氀搀攀爀⸀吀漀䠀琀洀氀匀琀爀椀渀最⠀吀愀最刀攀渀搀攀爀䴀漀搀攀⸀一漀爀洀愀氀⤀㬀ഀഀ        }਍ഀഀ        private static IHtmlString Raw(string text)਍        笀ഀഀ            return new HtmlString(text);਍        紀ഀഀ
਍        瀀爀椀瘀愀琀攀 猀琀愀琀椀挀 䤀䠀琀洀氀匀琀爀椀渀最 刀愀眀䨀匀⠀猀琀爀椀渀最 琀攀砀琀⤀ഀഀ        {਍            爀攀琀甀爀渀 渀攀眀 䠀琀洀氀匀琀爀椀渀最⠀䠀琀琀瀀唀琀椀氀椀琀礀⸀䨀愀瘀愀匀挀爀椀瀀琀匀琀爀椀渀最䔀渀挀漀搀攀⠀琀攀砀琀⤀⤀㬀ഀഀ        }਍ഀഀ        private static IHtmlString CssClass(string className)਍        笀ഀഀ            return new HtmlString((!className.IsEmpty()) ? " class=\"" + HttpUtility.HtmlAttributeEncode(className) + "\"" : String.Empty);਍        紀ഀഀ
਍        瀀爀椀瘀愀琀攀 猀琀愀琀椀挀 猀琀爀椀渀最 䜀攀琀刀漀眀匀琀礀氀攀⠀圀攀戀䜀爀椀搀 眀攀戀䜀爀椀搀Ⰰ 椀渀琀 爀漀眀䤀渀搀攀砀Ⰰ 猀琀爀椀渀最 爀漀眀匀琀礀氀攀Ⰰ 猀琀爀椀渀最 愀氀琀攀爀渀愀琀椀渀最刀漀眀匀琀礀氀攀Ⰰ 猀琀爀椀渀最 猀攀氀攀挀琀攀搀刀漀眀匀琀礀氀攀⤀ഀഀ        {਍            匀琀爀椀渀最䈀甀椀氀搀攀爀 猀琀礀氀攀 㴀 渀攀眀 匀琀爀椀渀最䈀甀椀氀搀攀爀⠀⤀㬀ഀഀ
਍            椀昀 ⠀爀漀眀䤀渀搀攀砀 ─ ㈀ 㴀㴀  ⤀ഀഀ            {਍                椀昀 ⠀℀匀琀爀椀渀最⸀䤀猀一甀氀氀伀爀䔀洀瀀琀礀⠀爀漀眀匀琀礀氀攀⤀⤀ഀഀ                {਍                    猀琀礀氀攀⸀䄀瀀瀀攀渀搀⠀爀漀眀匀琀礀氀攀⤀㬀ഀഀ                }਍            紀ഀഀ            else਍            笀ഀഀ                if (!String.IsNullOrEmpty(alternatingRowStyle))਍                笀ഀഀ                    style.Append(alternatingRowStyle);਍                紀ഀഀ            }਍ഀഀ            if (!String.IsNullOrEmpty(selectedRowStyle) && (rowIndex == webGrid.SelectedIndex))਍            笀ഀഀ                if (style.Length > 0)਍                笀ഀഀ                    style.Append(" ");਍                紀ഀഀ                style.Append(selectedRowStyle);਍            紀ഀഀ            return style.ToString();਍        紀ഀഀ
਍        瀀爀椀瘀愀琀攀 猀琀愀琀椀挀 䠀攀氀瀀攀爀刀攀猀甀氀琀 䘀漀爀洀愀琀⠀䘀甀渀挀㰀搀礀渀愀洀椀挀Ⰰ 漀戀樀攀挀琀㸀 昀漀爀洀愀琀Ⰰ 搀礀渀愀洀椀挀 愀爀最⤀ഀഀ        {਍            瘀愀爀 爀攀猀甀氀琀 㴀 昀漀爀洀愀琀⠀愀爀最⤀㬀ഀഀ            return new HelperResult(tw =>਍            笀ഀഀ                var helper = result as HelperResult;਍                椀昀 ⠀栀攀氀瀀攀爀 ℀㴀 渀甀氀氀⤀ഀഀ                {਍                    栀攀氀瀀攀爀⸀圀爀椀琀攀吀漀⠀琀眀⤀㬀ഀഀ                    return;਍                紀ഀഀ                IHtmlString htmlString = result as IHtmlString;਍                椀昀 ⠀栀琀洀氀匀琀爀椀渀最 ℀㴀 渀甀氀氀⤀ഀഀ                {਍                    琀眀⸀圀爀椀琀攀⠀栀琀洀氀匀琀爀椀渀最⤀㬀ഀഀ                    return;਍                紀ഀഀ                if (result != null)਍                笀ഀഀ                    tw.Write(HttpUtility.HtmlEncode(result));਍                紀ഀഀ            });਍        紀ഀഀ
਍        瀀爀椀瘀愀琀攀 猀琀愀琀椀挀 䤀䠀琀洀氀匀琀爀椀渀最 倀爀椀渀琀䄀琀琀爀椀戀甀琀攀猀⠀䤀䐀椀挀琀椀漀渀愀爀礀㰀猀琀爀椀渀最Ⰰ 漀戀樀攀挀琀㸀 愀琀琀爀椀戀甀琀攀猀⤀ഀഀ        {਍            瘀愀爀 戀甀椀氀搀攀爀 㴀 渀攀眀 匀琀爀椀渀最䈀甀椀氀搀攀爀⠀⤀㬀ഀഀ            foreach (var item in attributes)਍            笀ഀഀ                var value = Convert.ToString(item.Value, CultureInfo.InvariantCulture);਍                戀甀椀氀搀攀爀⸀䄀瀀瀀攀渀搀⠀✀ ✀⤀ഀഀ                    .Append(HttpUtility.HtmlEncode(item.Key))਍                    ⸀䄀瀀瀀攀渀搀⠀∀㴀尀∀∀⤀ഀഀ                    .Append(HttpUtility.HtmlAttributeEncode(value))਍                    ⸀䄀瀀瀀攀渀搀⠀✀∀✀⤀㬀ഀഀ            }਍            爀攀琀甀爀渀 渀攀眀 䠀琀洀氀匀琀爀椀渀最⠀戀甀椀氀搀攀爀⸀吀漀匀琀爀椀渀最⠀⤀⤀㬀ഀഀ        }਍ഀഀ        private static bool ModeEnabled(WebGridPagerModes mode, WebGridPagerModes modeCheck)਍        笀ഀഀ            return (mode & modeCheck) == modeCheck;਍        紀ഀഀ
਍        瀀爀漀琀攀挀琀攀搀 猀琀愀琀椀挀 䠀琀琀瀀䄀瀀瀀氀椀挀愀琀椀漀渀 䄀瀀瀀氀椀挀愀琀椀漀渀䤀渀猀琀愀渀挀攀ഀഀ        {਍            最攀琀 笀 爀攀琀甀爀渀 ⠀⠀䌀漀渀琀攀砀琀⸀䄀瀀瀀氀椀挀愀琀椀漀渀䤀渀猀琀愀渀挀攀⤀⤀㬀 紀ഀഀ        }਍    紀ഀഀ}਍

Apr 2, 2012 at 3:54 AM

oh. It might be because of uni-code thing.. Let me try with another git installer.

Apr 2, 2012 at 4:24 AM

Git-1.7.8-preview20111229-unicode.exe doesn't help me either.. 

Do you think I need to install some Vs extension? 

Apr 2, 2012 at 5:25 AM

Also, we just introduced a .gitattributes which (according to Paul Betts) should solve the auto-CRLF problem.

Note, if you already cloned, you may need to do "git reset --hard head" to force it to pull textual copies of the source code.

Apr 2, 2012 at 6:49 AM

I just clone the repository in new folder but I'm still getting the same error. The thing that I don't understand is that why I'm seeing Chinese characters instead of English. I tried both git-clone or download manually from the site. I got Chinese version of _WebGridRenderer.generated.cs. The only way that I can build is that to copy the English file and override the Chinese file. 

I posted the details with screenshots in my blog http://michaelsync.net/2012/04/01/building-asp-net-mvc-web-api-and-web-pages-source-code

I have some more questions as below. 

  1. Why does the file that I cloned or downloaded different from the one that I see on browser? Does it related to encoding issue on codeplex? I’m using Git-1.7.8-preview20111229-unicode.exe.
  2. What is RazorHelperGenerator? Do I need to register it somewhere? When can I get it?
  3. If you look at _WebGridRenderer.generated.csin codeplex repository,  you will see “RazorSingleFileGenerator” in [GeneratedCode] attribute. _WebGridRenderer.cs’s custom tool is set to “RazorHelperGenerator” so why not RazorHelperGenerator instead of ”RazorSingleFileGenerator”?
  4. Do I need to install any VS extension in order to build the Runtime.sln?

Thanks! 

Apr 2, 2012 at 7:38 AM

Paul Betts has diagnosed this as having some auto-generated files which are currently UTF16, which Git does not support. I'm working to figure out exactly how widespread the problem is.

Apr 2, 2012 at 7:48 AM
Edited Apr 2, 2012 at 7:49 AM
BradWilson wrote:

Paul Betts has diagnosed this as having some auto-generated files which are currently UTF16, which Git does not support. I'm working to figure out exactly how widespread the problem is.

Hi Brad,

 

Thanks for confirming the issue with UTF16 auto-generated files!

Could you please let me know where I can get the RazorHelperGenerator? Thanks! 

Apr 2, 2012 at 4:50 PM

I just checked in a fix for this file. Everybody who's having issues, please re-pull and verify that you're able to compile now.

Michael, I'm not sure where you can get RazorHelperGenerator. I'll ask one of the Web Pages guys to stop by this thread and answer the question.

Developer
Apr 2, 2012 at 5:58 PM

You can download the custom tool from the VS extension gallery http://visualstudiogallery.msdn.microsoft.com/1f6ec6ff-e89b-4c47-8e79-d2d68df894ec/. I'm going to look at fixing this to use a package instead so it's less obtuse to get up and running.

Apr 3, 2012 at 4:04 AM
Edited Apr 3, 2012 at 4:07 AM
BradWilson wrote:

I just checked in a fix for this file. Everybody who's having issues, please re-pull and verify that you're able to compile now.

Michael, I'm not sure where you can get RazorHelperGenerator. I'll ask one of the Web Pages guys to stop by this thread and answer the question.

 

Thanks Brad! I'm able to build the solution now.. Thanks a lot! 

 

pranavkm wrote:

You can download the custom tool from the VS extension gallery http://visualstudiogallery.msdn.microsoft.com/1f6ec6ff-e89b-4c47-8e79-d2d68df894ec/. I'm going to look at fixing this to use a package instead so it's less obtuse to get up and running.

I already installed both Razor Generator and Razor Single File Generator for MVC (old) but I'm still getting got the warning. 

Let me confirm whether my understanding is correct or not first.. 

The custom tool of _WebGridRenderer.cshtml of System.Web.Helpers is RazorHelperGenerator.

So, If I delete everything in _WebGridRenderer.generated.cs and I save  "_WebGridRenderer.cshtml" file after making some modifications, this file "_WebGridRenderer.generated.cs" should be re-generated. Am I right? 

 

Here is the steps that I did.

1. I deleted everything in  _WebGridRenderer.generated.cs.

2. Go to _WebGridRenderer.cshtml and modify a bit (like adding space or semi-comma) 

3. Save that file 

Expected Behivor: _WebGridRenderer.generated.cs. file should be re-generated. 

Actual Result: 

Got two warnings

  • Warning 1 C:\Michael Sync\git\aspnetwebstack-unicode\aspnetwebstack\src\System.Web.Helpers\WebGrid\_WebGridRenderer.cshtml: ASP.NET runtime error: There is no build provider registered for the extension '.cshtml'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.]
  • C:\Michael Sync\git\aspnetwebstack-unicode\aspnetwebstack\src\System.Web.Helpers\WebGrid\_WebGridRenderer.cshtml 1 1 System.Web.HelpersWarning 2 Cannot find custom tool 'RazorHelperGenerator' on this system. C:\Michael Sync\git\aspnetwebstack-unicode\aspnetwebstack\src\System.Web.Helpers\WebGrid\_WebGridRenderer.cshtml System.Web.Helpers

Got 5 errors because _WebGridRenderer.generated.cs. file is empty.