Here's my Helper class:

using System;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace MySite.Sites.Venue.Helper
{
    public static class DashboardWidgetHelper
    {
        public static IDisposable DashboardWidget(this HtmlHelper helper, string dashboardAction, int refreshInterval)
        {

            helper.ViewContext.Writer.Write(string.Format("<div data-widgetAction='{0}' data-refreshInterval='{1}'>", dashboardAction, refreshInterval));

            helper.RenderAction(dashboardAction);

            return new DashboardWidgetView(helper);
        }

        class DashboardWidgetView : IDisposable
        {
            private HtmlHelper helper;

            public DashboardWidgetView(HtmlHelper helper)
            {
                this.helper = helper;
            }

            public void Dispose()
            {
                this.helper.ViewContext.Writer.Write("</div>");
            }
        }
    }
}

An example of my controller action:

public ActionResult Fil()
{    
    return PartialView("~/Views/Dashboard/Widgets/_TopTenLists.cshtml");
}

My call on the View (Razor):

@Html.DashboardWidget("Fil", 1000 * 60 * 5)

And my partial located at ~/Views/Dashboard/Widgets/_TopTenLists.cshtml:

<h4 class="flag-horizontal">Top Ten Lists</h4>

The partial is rendering, but I am getting a namespace in the HTML output as well: enter image description here

Why am I getting this extra namespace string in my HTML body?

Related posts

Recent Viewed