Exemple #1
0
        /// <summary>
        /// Initializes the helpers used for view rendering.
        /// </summary>
        public override void InitHelpers()
        {
            base.InitHelpers();

            var baseHtmlHelper = new System.Web.Mvc.HtmlHelper<object>(this.ViewContext, this);

            this.Html = new HtmlHelper<object>(baseHtmlHelper);
        }
        /// <summary>
        /// Renders the specified React component
        /// </summary>
        /// <typeparam name="T">Type of the props</typeparam>
        /// <param name="htmlHelper">HTML helper</param>
        /// <param name="componentName">Name of the component</param>
        /// <param name="props">Props to initialise the component with</param>
        /// <param name="htmlTag">HTML tag to wrap the component in. Defaults to &lt;div&gt;</param>
        /// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
        /// <param name="clientOnly">Skip rendering server-side and only output client-side initialisation code. Defaults to <c>false</c></param>
        /// <param name="serverOnly">Skip rendering React specific data-attributes, container and client-side initialisation during server side rendering. Defaults to <c>false</c></param>
        /// <param name="containerClass">HTML class(es) to set on the container tag</param>
        /// <param name="exceptionHandler">A custom exception handler that will be called if a component throws during a render. Args: (Exception ex, string componentName, string containerId)</param>
        /// <param name="renderFunctions">Functions to call during component render</param>
        /// <returns>The component's HTML</returns>
        public static IHtmlString React <T>(
            this IHtmlHelper htmlHelper,
            string componentName,
            T props,
            string htmlTag        = null,
            string containerId    = null,
            bool clientOnly       = false,
            bool serverOnly       = false,
            string containerClass = null,
            Action <Exception, string, string> exceptionHandler = null,
            RenderFunctions renderFunctions = null
            )
        {
            return(new ActionHtmlString(writer =>
            {
                try
                {
                    var reactComponent = Environment.CreateComponent(componentName, props, containerId, clientOnly, serverOnly);
                    if (!string.IsNullOrEmpty(htmlTag))
                    {
                        reactComponent.ContainerTag = htmlTag;
                    }

                    if (!string.IsNullOrEmpty(containerClass))
                    {
                        reactComponent.ContainerClass = containerClass;
                    }

                    reactComponent.RenderHtml(writer, clientOnly, serverOnly, exceptionHandler, renderFunctions);
                }
                finally
                {
                    Environment.ReturnEngineToPool();
                }
            }));
        }
        public static System.Web.Mvc.MvcHtmlString GetSonBtnJs(this System.Web.Mvc.HtmlHelper htmlHelper)
        {
            System.Text.StringBuilder sbBtnJs = new System.Text.StringBuilder(1000);
            var menus = htmlHelper.ViewBag.sonBtns as List <Web.EFEntity.Menu>;

            if (menus != null)
            {
                for (var i = 0; i < menus.Count(); i++)
                {
                    sbBtnJs.Append("{");
                    sbBtnJs.Append("iconCls:'" + menus[i].ToolIco + "',");
                    sbBtnJs.Append("text:'" + menus[i].MenuName + "',");
                    sbBtnJs.Append("handler:function(){" + menus[i].ActionName + "();}");
                    sbBtnJs.Append("}");
                    if (i != menus.Count() - 1)
                    {
                        sbBtnJs.Append(",'-',");
                    }
                }
            }

            System.Web.Mvc.MvcHtmlString mvcStr = new System.Web.Mvc.MvcHtmlString(sbBtnJs.ToString());
            return(mvcStr);
        }
        /// <summary>
        /// Renders the specified React component, along with its client-side initialisation code.
        /// Normally you would use the <see cref="React{T}"/> method, but <see cref="ReactWithInit{T}"/>
        /// is useful when rendering self-contained partial views.
        /// </summary>
        /// <typeparam name="T">Type of the props</typeparam>
        /// <param name="htmlHelper">HTML helper</param>
        /// <param name="componentName">Name of the component</param>
        /// <param name="props">Props to initialise the component with</param>
        /// <param name="htmlTag">HTML tag to wrap the component in. Defaults to &lt;div&gt;</param>
        /// <param name="containerId">ID to use for the container HTML tag. Defaults to an auto-generated ID</param>
        /// <param name="clientOnly">Skip rendering server-side and only output client-side initialisation code. Defaults to <c>false</c></param>
        /// <param name="containerClass">HTML class(es) to set on the container tag</param>
        /// <param name="exceptionHandler">A custom exception handler that will be called if a component throws during a render. Args: (Exception ex, string componentName, string containerId)</param>
        /// <returns>The component's HTML</returns>
        public static IHtmlString ReactWithInit <T>(
            this IHtmlHelper htmlHelper,
            string componentName,
            T props,
            string htmlTag        = null,
            string containerId    = null,
            bool clientOnly       = false,
            string containerClass = null,
            Action <Exception, string, string> exceptionHandler = null
            )
        {
            return(new ActionHtmlString(writer =>
            {
                try
                {
                    var reactComponent = Environment.CreateComponent(componentName, props, containerId, clientOnly);
                    if (!string.IsNullOrEmpty(htmlTag))
                    {
                        reactComponent.ContainerTag = htmlTag;
                    }

                    if (!string.IsNullOrEmpty(containerClass))
                    {
                        reactComponent.ContainerClass = containerClass;
                    }

                    reactComponent.RenderHtml(writer, clientOnly, exceptionHandler: exceptionHandler);
                    writer.WriteLine();
                    WriteScriptTag(writer, bodyWriter => reactComponent.RenderJavaScript(bodyWriter));
                }
                finally
                {
                    Environment.ReturnEngineToPool();
                }
            }));
        }
        //Overload para a adicionar um ícone à esquerda.
        /// <summary>
        /// Creates 'li' HTML tags with contextual styling based on the actual request, with an glyphicon to the left.
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="linkText">Text to be displayed.</param>
        /// <param name="actionName">Action to point to.</param>
        /// <param name="controllerName">Controller to point to.</param>
        /// <param name="iconClass">The glyphicon icon class. Can be without the 'glyphicon' and 'glyphicon-' values. Refeer to the actual version or Bootstrap in this project for the complete list of available Glyphicon at http://getbootstrap.com/components/#glyphicons</param>
        /// <returns>Returns a HTML 'li' string with the given context.</returns>
        public static MvcHtmlString MenuLink(this System.Web.Mvc.HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string iconClass)
        {
            // Get the Action and the Controller for the actual request.
            var currentAction     = htmlHelper.ViewContext.RouteData.GetRequiredString("action");
            var currentController = htmlHelper.ViewContext.RouteData.GetRequiredString("controller");

            // Creates the icon 'span' tag.
            var icon = new TagBuilder("span");

            // Make sure it adds the icon if the user inserts all the glyphicon classes or only the name of the glyphicon.
            icon.AddCssClass("glyphicon glyphicon-" + iconClass.Replace("glyphicon glyphicon-", ""));

            // Creates the 'a' tag.
            var link = new TagBuilder("a")
            {
                InnerHtml = icon + "&nbsp;&nbsp;" + linkText // Adds two spaces between the icon and the text.
            };

            // Adds the link according to the given action and controllers parameters.
            link.Attributes.Add("href", "/" + controllerName + "/" + actionName);

            // Creates the 'li' tag.
            var li = new TagBuilder("li")
            {
                InnerHtml = link.ToString()
            };

            // Checks if the user's actual page is the point page at the <li>. If it is, put an 'active' css class to it for contextual displaying.
            // Turns all strings to lower casing to evade casing issues not setting the 'active' css correctly.
            if (controllerName.ToLower() == currentController.ToLower() && actionName.ToLower() == currentAction.ToLower())
            {
                li.AddCssClass("active");
            }

            return(new MvcHtmlString(li.ToString()));
        }
 /// <summary>
 /// 为 <see cref="HtmlHelper"/> 对象扩展 numberbox 元素。
 /// </summary>
 /// <typeparam name="TModel">数据模型类型。</typeparam>
 /// <typeparam name="TProperty">绑定的属性的类型。</typeparam>
 /// <param name="htmlHelper"></param>
 /// <param name="expression">指定绑定属性的表达式。</param>
 /// <param name="settings">参数选项。</param>
 /// <returns></returns>
 public static HtmlHelper <TModel> NumberBox <TModel, TProperty>(this System.Web.Mvc.HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, NumberBoxSettings settings = null)
 {
     return(new HtmlHelper <TModel>().NumberBox(expression, settings));
 }
        public static IHtmlContent VendrCheckoutPartial(this IHtmlHelper helper, string partialName, object model)
        {
            var pathHelper = GetPathHelper(helper);

            return(helper.Partial(pathHelper.GetVendrCheckoutPartialViewPath(partialName), model));
        }
 /// <summary>
 /// 为 <see cref="HtmlHelper"/> 对象扩展 numberbox 元素。
 /// </summary>
 /// <param name="htmlHelper"></param>
 /// <param name="exp">属性名或使用 txt 作为前缀的 ID 名称。</param>
 /// <param name="settings">参数选项。</param>
 /// <returns></returns>
 public static HtmlHelper NumberBox(this System.Web.Mvc.HtmlHelper htmlHelper, string exp, NumberBoxSettings settings = null)
 {
     return(new HtmlHelper().NumberBox(exp, settings));
 }
Exemple #9
0
		public PartHelper(System.Web.Mvc.HtmlHelper helper, ContentItem item)
		{
			this.Html = helper;
			this.item = item;
		}
 private static PathHelper GetPathHelper(IHtmlHelper helper)
 => (PathHelper)helper.ViewContext.HttpContext.RequestServices.GetService(typeof(PathHelper));
 /// <summary>
 /// Gets the java script resources.
 /// </summary>
 /// <param name="html">The HTML.</param>
 /// <returns>Array with JavaScript resources</returns>
 public string[] GetJavaScriptResources(System.Web.Mvc.HtmlHelper html)
 {
     return(jsAccessor.GetJavaScriptResources(html));
 }
Exemple #12
0
        ///<summary>
        ///	Displays a configurable paging control for instances of PagedList.
        ///</summary>
        ///<param name = "html">This method is meant to hook off HtmlHelper as an extension method.</param>
        ///<param name = "list">The PagedList to use as the data source.</param>
        ///<param name = "generatePageUrl">A function that takes the page number  of the desired page and returns a URL-string that will load that page.</param>
        ///<param name = "options">Formatting options.</param>
        ///<returns>Outputs the paging control HTML.</returns>
        public static HtmlString PagedListPager(this IHtmlHelper html,
                                                IPagedList list,
                                                Func <int, string> generatePageUrl,
                                                PagedListRenderOptions options)
        {
            if (options.Display == PagedListDisplayMode.Never || (options.Display == PagedListDisplayMode.IfNeeded && list.PageCount <= 1))
            {
                return(null);
            }

            var listItemLinks = new List <TagBuilder>();

            //calculate start and end of range of page numbers
            var firstPageToDisplay   = 1;
            var lastPageToDisplay    = list.PageCount;
            var pageNumbersToDisplay = lastPageToDisplay;

            if (options.MaximumPageNumbersToDisplay.HasValue && list.PageCount > options.MaximumPageNumbersToDisplay)
            {
                // cannot fit all pages into pager
                var maxPageNumbersToDisplay = options.MaximumPageNumbersToDisplay.Value;
                firstPageToDisplay = list.PageNumber - maxPageNumbersToDisplay / 2;
                if (firstPageToDisplay < 1)
                {
                    firstPageToDisplay = 1;
                }
                pageNumbersToDisplay = maxPageNumbersToDisplay;
                lastPageToDisplay    = firstPageToDisplay + pageNumbersToDisplay - 1;
                if (lastPageToDisplay > list.PageCount)
                {
                    firstPageToDisplay = list.PageCount - maxPageNumbersToDisplay + 1;
                }
            }

            //first
            if (options.DisplayLinkToFirstPage == PagedListDisplayMode.Always || (options.DisplayLinkToFirstPage == PagedListDisplayMode.IfNeeded && firstPageToDisplay > 1))
            {
                listItemLinks.Add(First(list, generatePageUrl, options));
            }

            //previous
            if (options.DisplayLinkToPreviousPage == PagedListDisplayMode.Always || (options.DisplayLinkToPreviousPage == PagedListDisplayMode.IfNeeded && !list.IsFirstPage))
            {
                listItemLinks.Add(Previous(list, generatePageUrl, options));
            }

            //text
            if (options.DisplayPageCountAndCurrentLocation)
            {
                listItemLinks.Add(PageCountAndLocationText(list, options));
            }

            //text
            if (options.DisplayItemSliceAndTotal)
            {
                listItemLinks.Add(ItemSliceAndTotalText(list, options));
            }

            //page
            if (options.DisplayLinkToIndividualPages)
            {
                //if there are previous page numbers not displayed, show an ellipsis
                if (options.DisplayEllipsesWhenNotShowingAllPageNumbers && firstPageToDisplay > 1)
                {
                    listItemLinks.Add(Ellipses(options));
                }

                foreach (var i in Enumerable.Range(firstPageToDisplay, pageNumbersToDisplay))
                {
                    //show delimiter between page numbers
                    if (i > firstPageToDisplay && !string.IsNullOrWhiteSpace(options.DelimiterBetweenPageNumbers))
                    {
                        listItemLinks.Add(WrapInListItem(options.DelimiterBetweenPageNumbers));
                    }

                    //show page number link
                    listItemLinks.Add(Page(i, list, generatePageUrl, options));
                }

                //if there are subsequent page numbers not displayed, show an ellipsis
                if (options.DisplayEllipsesWhenNotShowingAllPageNumbers && (firstPageToDisplay + pageNumbersToDisplay - 1) < list.PageCount)
                {
                    listItemLinks.Add(Ellipses(options));
                }
            }

            //next
            if (options.DisplayLinkToNextPage == PagedListDisplayMode.Always || (options.DisplayLinkToNextPage == PagedListDisplayMode.IfNeeded && !list.IsLastPage))
            {
                listItemLinks.Add(Next(list, generatePageUrl, options));
            }

            //last
            if (options.DisplayLinkToLastPage == PagedListDisplayMode.Always || (options.DisplayLinkToLastPage == PagedListDisplayMode.IfNeeded && lastPageToDisplay < list.PageCount))
            {
                listItemLinks.Add(Last(list, generatePageUrl, options));
            }

            if (listItemLinks.Any())
            {
                //append class to first item in list?
                if (!string.IsNullOrWhiteSpace(options.ClassToApplyToFirstListItemInPager))
                {
                    listItemLinks.First().AddCssClass(options.ClassToApplyToFirstListItemInPager);
                }

                //append class to last item in list?
                if (!string.IsNullOrWhiteSpace(options.ClassToApplyToLastListItemInPager))
                {
                    listItemLinks.Last().AddCssClass(options.ClassToApplyToLastListItemInPager);
                }

                //append classes to all list item links
                foreach (var li in listItemLinks)
                {
                    foreach (var c in options.LiElementClasses ?? Enumerable.Empty <string>())
                    {
                        li.AddCssClass(c);
                    }
                }
            }

            //collapse all of the list items into one big string
            var listItemLinksString = listItemLinks.Aggregate(
                new StringBuilder(),
                (sb, listItem) => sb.Append(TagBuilderToString(listItem)),
                sb => sb.ToString()
                );

            var ul = new TagBuilder("ul");

            AppendHtml(ul, listItemLinksString);
            foreach (var c in options.UlElementClasses ?? Enumerable.Empty <string>())
            {
                ul.AddCssClass(c);
            }

            var outerDiv = new TagBuilder("div");

            foreach (var c in options.ContainerDivClasses ?? Enumerable.Empty <string>())
            {
                outerDiv.AddCssClass(c);
            }
            AppendHtml(outerDiv, TagBuilderToString(ul));

            return(new HtmlString(TagBuilderToString(outerDiv)));
        }
Exemple #13
0
        public static SchedulerSettings GetSchedulerSettings(this System.Web.Mvc.HtmlHelper customHtml)
        {
            SchedulerSettings settings = new SchedulerSettings();

            settings.Name = "scheduler";

            settings.InitClientAppointment = (sched, evargs) => {
                evargs.Properties.Add(DevExpress.Web.ASPxScheduler.ClientSideAppointmentFieldNames.AppointmentType, evargs.Appointment.Type);
                evargs.Properties.Add(DevExpress.Web.ASPxScheduler.ClientSideAppointmentFieldNames.Subject, evargs.Appointment.Subject);
            };

            settings.PopupMenuShowing = (sched, evargs) => {
                if (evargs.Menu.MenuId == SchedulerMenuItemId.AppointmentMenu)
                {
                    evargs.Menu.ClientSideEvents.PopUp = "OnAppointmentMenuPopup";
                }
            };

            settings.CallbackRouteValues        = new { Controller = "Home", Action = "SchedulerPartial" };
            settings.EditAppointmentRouteValues = new { Controller = "Home", Action = "EditAppointment" };
            settings.CustomActionRouteValues    = new { Controller = "Home", Action = "CustomCallBackAction" };

            settings.Storage.Appointments.Assign(SchedulerDataHelper.DefaultAppointmentStorage);
            settings.Storage.Resources.Assign(SchedulerDataHelper.DefaultResourceStorage);

            settings.Storage.EnableReminders = true;
            settings.GroupType = SchedulerGroupType.Resource;
            settings.Views.DayView.Styles.ScrollAreaHeight = 400;
            settings.Start = DateTime.Now;

            settings.AppointmentFormShowing = (sender, e) => {
                var scheduler = sender as MVCxScheduler;
                if (scheduler != null)
                {
                    e.Container = new CustomAppointmentTemplateContainer(scheduler);
                }
            };

            settings.OptionsForms.RecurrenceFormName = "appointmentRecurrenceForm";

            settings.OptionsForms.SetAppointmentFormTemplateContent(c => {
                var container = (CustomAppointmentTemplateContainer)c;
                ModelAppointment modelAppointment = new ModelAppointment()
                {
                    ID          = container.Appointment.Id == null ? -1 : (int)container.Appointment.Id,
                    Subject     = container.Appointment.Subject,
                    Location    = container.Appointment.Location,
                    StartTime   = container.Appointment.Start,
                    EndTime     = container.Appointment.End,
                    AllDay      = container.Appointment.AllDay,
                    Description = container.Appointment.Description,
                    EventType   = (int)container.Appointment.Type,
                    Status      = Convert.ToInt32(container.Appointment.StatusKey),
                    Label       = Convert.ToInt32(container.Appointment.LabelKey),
                    CustomInfo  = container.CustomInfo,

                    CompanyID = container.CompanyID,
                    ContactID = container.ContactID,

                    HasReminder = container.Appointment.HasReminder,
                    Reminder    = container.Appointment.Reminder,
                    OwnerId     = Convert.ToInt32(container.Appointment.ResourceId)
                };

                customHtml.ViewBag.DeleteButtonEnabled = container.CanDeleteAppointment;

                (container.ResourceDataSource as ListEditItemCollection).RemoveAt(0);
                customHtml.ViewBag.ResourceDataSource = container.ResourceDataSource;
                customHtml.ViewBag.StatusDataSource   = container.StatusDataSource;
                customHtml.ViewBag.LabelDataSource    = container.LabelDataSource;
                customHtml.ViewBag.AppointmentRecurrenceFormSettings = CreateAppointmentRecurrenceFormSettings(container);
                customHtml.ViewBag.ReminderDataSource = container.ReminderDataSource;
                customHtml.ViewBag.IsBaseAppointment  = container.Appointment.Type == AppointmentType.Normal || container.Appointment.Type == AppointmentType.Pattern;

                customHtml.ViewBag.CompaniesDataSource = GetCompanies();
                customHtml.ViewBag.ContactsDataSource  = GetCompanyContacts(container.CompanyID);

                customHtml.RenderPartial("CustomAppointmentFormPartial", modelAppointment);
            });
            return(settings);
        }
Exemple #14
0
 public static string Localized(this System.Web.Mvc.HtmlHelper htmlHelper, string category, string key, params object[] args)
 {
     return(Localized(category, key, args));
 }
Exemple #15
0
        /// <summary>
        /// 上图分页右边的 页数信息
        /// </summary>
        /// <param name="html"></param>
        /// <param name="pagingInfo"></param>
        /// <param name="pageUrl"></param>
        /// <returns></returns>
        public static MvcHtmlString PageLinks(this System.Web.Mvc.HtmlHelper html, PagingInfo pagingInfo, Func <int, string> pageUrl)
        {
            //新建StringBuilder实例result       将他作为最终的html字符串生成相应的标签
            StringBuilder result = new StringBuilder();

            if (pagingInfo.TotalPages != 0)
            {
                //首页 前页
                TagBuilder tagPrior = new TagBuilder("a");
                tagPrior.InnerHtml = "上一页";
                //将标签tostring后 追加到StringBuilder
                if (pagingInfo.CurrentPage != 1)
                {
                    tagPrior.MergeAttribute("href", pageUrl(pagingInfo.CurrentPage - 1));
                }
                else
                {
                    tagPrior.MergeAttribute("class", "prev-disabled");
                }
                result.Append(tagPrior.ToString());


                //1
                if (pagingInfo.TotalPages >= 1)
                {
                    TagBuilder one = new TagBuilder("a");
                    one.InnerHtml = "1";
                    one.MergeAttribute("href", pageUrl(1));
                    if (pagingInfo.CurrentPage == 1)
                    {
                        one.MergeAttribute("class", "current");
                    }
                    result.Append(one.ToString());
                }

                //2
                if (pagingInfo.TotalPages >= 2)
                {
                    TagBuilder two = new TagBuilder("a");
                    two.InnerHtml = "2";
                    two.MergeAttribute("href", pageUrl(2));
                    if (pagingInfo.CurrentPage == 2)
                    {
                        two.MergeAttribute("class", "current");
                    }
                    result.Append(two.ToString());
                }


                if (pagingInfo.CurrentPage > 5 && pagingInfo.TotalPages != 6)
                {
                    TagBuilder span = new TagBuilder("span");
                    span.InnerHtml = "...";
                    span.MergeAttribute("class", "text");
                    result.Append(span.ToString());
                }

                int index = pagingInfo.CurrentPage > 2 ?
                            pagingInfo.CurrentPage :
                            3;

                //1,2,3,4,5的时候
                if (pagingInfo.CurrentPage <= 5)
                {
                    int start = 3;
                    for (int i = start; i < 8 && i <= pagingInfo.TotalPages; i++)
                    {
                        TagBuilder temp = new TagBuilder("a");
                        temp.InnerHtml = i.ToString();
                        temp.MergeAttribute("href", pageUrl(i));
                        if (i == pagingInfo.CurrentPage)
                        {
                            temp.MergeAttribute("class", "current");
                        }
                        result.Append(temp.ToString());
                    }

                    if (pagingInfo.TotalPages > 7)
                    {
                        TagBuilder span = new TagBuilder("span");
                        span.InnerHtml = "...";
                        span.MergeAttribute("class", "text");
                        result.Append(span.ToString());
                    }
                }

                //后面不足5个
                if (pagingInfo.CurrentPage > 5 && pagingInfo.CurrentPage + 5 > pagingInfo.TotalPages)
                {
                    int start = pagingInfo.TotalPages - 4;
                    if (start == 2)
                    {
                        start += 1;
                    }
                    for (int i = start; i <= pagingInfo.TotalPages; i++)
                    {
                        TagBuilder temp = new TagBuilder("a");
                        temp.InnerHtml = i.ToString();
                        temp.MergeAttribute("href", pageUrl(i));
                        if (i == pagingInfo.CurrentPage)
                        {
                            temp.MergeAttribute("class", "current");
                        }
                        result.Append(temp.ToString());
                    }
                }

                //大于5的时候
                if (pagingInfo.CurrentPage > 5 && pagingInfo.CurrentPage + 5 <= pagingInfo.TotalPages)
                {
                    //index = pagingInfo.CurrentPage % 5;
                    for (int i = pagingInfo.CurrentPage; i < pagingInfo.CurrentPage + 5; i++)
                    {
                        TagBuilder temp = new TagBuilder("a");
                        temp.InnerHtml = (i - 2).ToString();
                        temp.MergeAttribute("href", pageUrl(i - 2));
                        if (i == pagingInfo.CurrentPage + 2)
                        {
                            temp.MergeAttribute("class", "current");
                        }
                        result.Append(temp.ToString());
                    }
                    TagBuilder span = new TagBuilder("span");
                    span.InnerHtml = "...";
                    span.MergeAttribute("class", "text");
                    result.Append(span.ToString());
                }


                //下一页
                TagBuilder tagAfter = new TagBuilder("a");
                tagAfter.InnerHtml = "下一页";
                if (pagingInfo.CurrentPage != pagingInfo.TotalPages)
                {
                    tagAfter.MergeAttribute("href", pageUrl(pagingInfo.CurrentPage + 1));
                }
                else
                {
                    tagAfter.MergeAttribute("class", "next-disabled");
                }
                result.Append(tagAfter.ToString());
            }

            //创建html标签 返回!!!
            return(MvcHtmlString.Create(result.ToString()));
        }
 /// <summary>
 /// 为 <see cref="HtmlHelper"/> 对象扩展 datetimespinner 元素。
 /// </summary>
 /// <param name="htmlHelper"></param>
 /// <param name="exp">属性名或使用 txt 作为前缀的 ID 名称。</param>
 /// <param name="settings">参数选项。</param>
 /// <returns></returns>
 public static HtmlHelper DateTimeSpinner(this System.Web.Mvc.HtmlHelper htmlHelper, string exp, DateTimeSpinnerSettings settings = null)
 {
     return(new HtmlHelper().DateTimeSpinner(exp, settings));
 }
Exemple #17
0
        public static System.Web.Mvc.MvcHtmlString ShonizGrid <T>(this System.Web.Mvc.HtmlHelper helper, GridModel <T> gridModel)
        {
            var gridContext = new GridContext <T>(gridModel);

            return(gridContext.InitialGrid());
        }
Exemple #18
0
 /// <summary>
 /// Gets the custom styles.
 /// </summary>
 /// <param name="html">The HTML.</param>
 /// <returns>Custom style</returns>
 public string GetCustomStyles(System.Web.Mvc.HtmlHelper html)
 {
     return(styleAccessor.GetCustomStyles(html));
 }
 public static HelperResult TableHeader <TModel, TKey>(System.Web.Mvc.HtmlHelper helper, Expression <Func <TModel, TKey> > expression)
 {
     return(TableHeader(helper, expression, null));
 }
 /// <summary>
 /// Returns the Current Version from the AssemblyInfo.cs file.
 /// </summary>
 /// <param name="helper"></param>
 /// <returns></returns>
 public static string CurrentVersion(this System.Web.Mvc.HtmlHelper helper)
 {
     return(Version.Value);
 }
        string GetContentAsGrid(Node nMail)
        {
            string gridHTML = null;
            // Try as grid
            var pc = Umbraco.Web.UmbracoContext.Current?.ContentCache?.GetById(nMail.Id);
            string alias = EnmUmbracoPropertyAlias.body.ToString();
            if (pc != null)
            {
                var p = pc.GetProperty(alias);
                if (p == null)
                    return null;
                var model = p.Value;
                if (model == null)
                    return null;
                var cc = new System.Web.Mvc.ControllerContext
                {
                    RequestContext = Umbraco.Web.UmbracoContext.Current.HttpContext.Request.RequestContext
                };

                var viewContext = new System.Web.Mvc.ViewContext(cc, new FakeView(), new System.Web.Mvc.ViewDataDictionary(model), new System.Web.Mvc.TempDataDictionary(), new StringWriter());
                if (!viewContext.RouteData.Values.ContainsKey("controller"))
                    viewContext.RouteData.Values.Add("controller", "cheese");

                var htmlHelper = new System.Web.Mvc.HtmlHelper(viewContext, new System.Web.Mvc.ViewPage());
                gridHTML = Umbraco.Web.GridTemplateExtensions.GetGridHtml(htmlHelper, pc, alias).ToHtmlString();
            }
            return gridHTML;
        }
Exemple #22
0
        public override void RenderPart(System.Web.Mvc.HtmlHelper html, ContentItem part, System.IO.TextWriter writer = null)
        {
            bool designMode = ControlPanelExtensions.GetControlPanelState(html).HasFlag(ControlPanelState.DragDrop);

            html.ViewContext.Writer.Write(GetHtml(part as HtmlAnchor, designMode));
        }
Exemple #23
0
        public static System.Web.IHtmlString DtxTimeDifference
            (this System.Web.Mvc.HtmlHelper helper, System.DateTime dateTime)
        {
            string strResult = string.Empty;

            System.DateTime dtmNow = System.DateTime.Now;

            if (dtmNow <= dateTime)
            {
                return(helper.Raw(string.Empty));
            }

            System.TimeSpan dtmDifference =
                dtmNow - dateTime;

            if (dtmDifference < new System.TimeSpan(0, 1, 0))
            {
                strResult =
                    string.Format("{0} ثانيه قبل", dtmDifference.Seconds);

                return(helper.Raw(strResult));
            }

            if (dtmDifference < new System.TimeSpan(1, 0, 0))
            {
                strResult =
                    string.Format("{0} دقيقه قبل", dtmDifference.Minutes);

                return(helper.Raw(strResult));
            }

            if (dtmDifference < new System.TimeSpan(1, 0, 0, 0))
            {
                strResult =
                    string.Format("{0} ساعت و {1} دقيقه قبل", dtmDifference.Hours, dtmDifference.Minutes);

                return(helper.Raw(strResult));
            }

            if (dtmDifference < new System.TimeSpan(2, 0, 0, 0))
            {
                strResult = "ديروز";

                return(helper.Raw(strResult));
            }

            if (dtmDifference < new System.TimeSpan(7, 0, 0, 0))
            {
                switch (dateTime.DayOfWeek)
                {
                case System.DayOfWeek.Saturday:
                {
                    strResult = "شنبه";
                    break;
                }

                case System.DayOfWeek.Sunday:
                {
                    strResult = "يکشنبه";
                    break;
                }

                case System.DayOfWeek.Monday:
                {
                    strResult = "دوشنبه";
                    break;
                }

                case System.DayOfWeek.Tuesday:
                {
                    strResult = "سه شنبه";
                    break;
                }

                case System.DayOfWeek.Wednesday:
                {
                    strResult = "چهارشنبه";
                    break;
                }

                case System.DayOfWeek.Thursday:
                {
                    strResult = "پنجشنبه";
                    break;
                }

                case System.DayOfWeek.Friday:
                {
                    strResult = "جمعه";
                    break;
                }
                }

                return(helper.Raw(strResult));
            }

            System.Globalization.PersianCalendar oPersianCalendar =
                new System.Globalization.PersianCalendar();

            int intMonth = oPersianCalendar.GetMonth(dateTime);
            int intDay   = oPersianCalendar.GetDayOfMonth(dateTime);

            string strMonth = string.Empty;

            switch (intMonth)
            {
            case 1:
            {
                strMonth = "فروردين";
                break;
            }

            case 2:
            {
                strMonth = "ارديبهشت";
                break;
            }

            case 3:
            {
                strMonth = "خرداد";
                break;
            }

            case 4:
            {
                strMonth = "تير";
                break;
            }

            case 5:
            {
                strMonth = "مرداد";
                break;
            }

            case 6:
            {
                strMonth = "شهريور";
                break;
            }

            case 7:
            {
                strMonth = "مهر";
                break;
            }

            case 8:
            {
                strMonth = "آبان";
                break;
            }

            case 9:
            {
                strMonth = "آذر";
                break;
            }

            case 10:
            {
                strMonth = "دی";
                break;
            }

            case 11:
            {
                strMonth = "بهمن";
                break;
            }

            case 12:
            {
                strMonth = "اسفند";
                break;
            }
            }

            strResult =
                string.Format("{0} {1}", intDay, strMonth);

            return(helper.Raw(strResult));
        }
 /// <summary>
 /// 为 <see cref="HtmlHelper"/> 对象扩展 datetimespinner 元素。
 /// </summary>
 /// <typeparam name="TModel">数据模型类型。</typeparam>
 /// <typeparam name="TProperty">绑定的属性的类型。</typeparam>
 /// <param name="htmlHelper"></param>
 /// <param name="expression">指定绑定属性的表达式。</param>
 /// <param name="settings">参数选项。</param>
 /// <returns></returns>
 public static HtmlHelper <TModel> DateTimeSpinner <TModel, TProperty>(this System.Web.Mvc.HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, DateTimeSpinnerSettings settings = null)
 {
     return(new HtmlHelper <TModel>().DateTimeSpinner(expression, settings));
 }
        public static System.Web.WebPages.HelperResult RequestTypeFilter(System.Web.Mvc.HtmlHelper html, RequestListModel model, Func <RequestListGetModel, string> reloadUrl)
        {
            return(new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 17 "..\..\App_Code\RequestHelpers.cshtml"

                var current = model.RequestTypeFilter;


#line default
#line hidden

                WriteLiteralTo(@__razor_helper_writer, "    <div class=\"ui-dropdown-button ui-has-hint FilterButton");



#line 20 "..\..\App_Code\RequestHelpers.cshtml"
                WriteTo(@__razor_helper_writer, model.RequestTypeFilter == null ? "" : " Active");

#line default
#line hidden

                WriteLiteralTo(@__razor_helper_writer, "\"\r\n        hint-text=\"");



#line 21 "..\..\App_Code\RequestHelpers.cshtml"
                WriteTo(@__razor_helper_writer, current == null ? "Filter by type" : "Showing " + current.RequestType.Name);

#line default
#line hidden

                WriteLiteralTo(@__razor_helper_writer, "\">&nbsp;</div>\r\n");



                WriteLiteralTo(@__razor_helper_writer, "    <div class=\"ui-dropdown ui-scrolling FilterOptions\" style=\"display: none\">\r\n");



#line 23 "..\..\App_Code\RequestHelpers.cshtml"
                foreach (var rt in model.UsedRequestTypes.Select(rt => new RequestTypeFilterItem((PluginRequestType)rt)).OrderBy(rt => rt.Name).StartWith(new RequestTypeFilterItem()))
                {
                    var m = model.List.OriginalRequest;
                    m.RequestTypeFilter = rt.ID;

#line default
#line hidden

                    WriteLiteralTo(@__razor_helper_writer, "            <a href=\"");



#line 27 "..\..\App_Code\RequestHelpers.cshtml"
                    WriteTo(@__razor_helper_writer, html.Raw(reloadUrl(m)));

#line default
#line hidden

                    WriteLiteralTo(@__razor_helper_writer, "\" class=\"GridReloadLink");



#line 27 "..\..\App_Code\RequestHelpers.cshtml"
                    WriteTo(@__razor_helper_writer, rt.ID == model.List.OriginalRequest.RequestTypeFilter ? " Selected" : "");

#line default
#line hidden

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



#line 27 "..\..\App_Code\RequestHelpers.cshtml"
                    WriteTo(@__razor_helper_writer, rt.Name);

#line default
#line hidden

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



#line 28 "..\..\App_Code\RequestHelpers.cshtml"
                }

#line default
#line hidden

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



#line 30 "..\..\App_Code\RequestHelpers.cshtml"

#line default
#line hidden
            }));
        }
Exemple #26
0
 /// <summary>
 /// Localizes the strings from MVC using specified key.
 /// </summary>
 /// <param name="htmlHelper"></param>
 /// <param name="category">The category.</param>
 /// <param name="key">The key.</param>
 /// <returns></returns>
 public static string Localize(this System.Web.Mvc.HtmlHelper htmlHelper, string category, string key)
 {
     return(Localize(category, key));
 }
 public void Init()
 {
     this._htmlHelper = MvcHelper.GetHtmlHelper();
 }
 /// <summary>
 /// Gets the custom java script.
 /// </summary>
 /// <param name="html">The HTML.</param>
 /// <returns>Custom JavaScript</returns>
 public string[] GetCustomJavaScript(System.Web.Mvc.HtmlHelper html)
 {
     return(jsAccessor.GetCustomJavaScript(html));
 }
 public void Cleanup()
 {
     this._htmlHelper = null;
 }
Exemple #30
0
 ///<summary>
 ///	Displays a configurable paging control for instances of PagedList.
 ///</summary>
 ///<param name = "html">This method is meant to hook off HtmlHelper as an extension method.</param>
 ///<param name = "list">The PagedList to use as the data source.</param>
 ///<param name = "generatePageUrl">A function that takes the page number of the desired page and returns a URL-string that will load that page.</param>
 ///<returns>Outputs the paging control HTML.</returns>
 public static HtmlString PagedListPager(this IHtmlHelper html,
                                         IPagedList list,
                                         Func <int, string> generatePageUrl)
 {
     return(PagedListPager(html, list, generatePageUrl, new PagedListRenderOptions()));
 }
Exemple #31
0
 public static string LabelSomething(this System.Web.Mvc.HtmlHelper helper, string target, string text)
 {
     return(string.Format("<label for='{0}'>{1}</label>", target, text));
 }
Exemple #32
0
 ///<summary>
 /// Displays a configurable "Go To Page:" form for instances of PagedList.
 ///</summary>
 ///<param name="html">This method is meant to hook off HtmlHelper as an extension method.</param>
 ///<param name="list">The PagedList to use as the data source.</param>
 ///<param name="formAction">The URL this form should submit the GET request to.</param>
 ///<returns>Outputs the "Go To Page:" form HTML.</returns>
 public static HtmlString PagedListGoToPageForm(this IHtmlHelper html,
                                                IPagedList list,
                                                string formAction)
 {
     return(PagedListGoToPageForm(html, list, formAction, "page"));
 }
 private static PathHelper GetPathHelper(IHtmlHelper helper)
 => (PathHelper)Current.Factory.GetInstance(typeof(PathHelper));