예제 #1
0
 public static string UrlWithActionFragment(this UrlHelper urlHelper, ActionResult fragmentAction)
 {
     return String.Format("{0}#{1}",
                 RouteTable.Routes.GetVirtualPathForArea(urlHelper.RequestContext,
                                                 new RouteValueDictionary(new
                                                 {
                                                     area = string.Empty,
                                                     controller = fragmentAction.AsMVCResult().Controller,
                                                     action = string.Empty,
                                                 })).VirtualPath,
                  fragmentAction.AsMVCResult().Action);
 }
예제 #2
0
        public static MvcHtmlString ActionLinkWithFragment(this HtmlHelper htmlHelper, string text, ActionResult fragmentAction, string cssClass = null, string dataOptions = null)
        {
            var mvcActionResult = fragmentAction.AsMVCResult() as IMvcResult;

            if (mvcActionResult == null)
                return null;

            var options = string.Empty;

            var actionLink = string.Format("{0}#{1}",
                        RouteTable.Routes.GetVirtualPathForArea(htmlHelper.ViewContext.RequestContext,
                                                        new RouteValueDictionary(new
                                                        {
                                                            area = string.Empty,
                                                            controller = mvcActionResult.Controller,
                                                            action = string.Empty,
                                                        })).VirtualPath,
                         mvcActionResult.Action);

            if (!string.IsNullOrEmpty(dataOptions))
                options = "data-options=\"" + dataOptions.Trim() + "\"";

            return new MvcHtmlString(string.Format("<a id=\"{0}\" href=\"{1}\" class=\"jqAddress {2}\" {3}>{4}</a>", Guid.NewGuid(), actionLink,
                (string.IsNullOrEmpty(cssClass) ? string.Empty : cssClass.Trim()),
                (string.IsNullOrEmpty(options) ? string.Empty : options.Trim()), text));
        }
예제 #3
0
        public static MvcForm BeginJqueryForm(this AjaxHelper ajaxHelper, string formId, ActionResult actionResult, bool isAjax, string eventName, string updateId, string cssClassNames)
        {
            var callInfo = actionResult.AsMVCResult();

            return BeginJqueryForm(ajaxHelper, callInfo.Action, callInfo.Controller, formId, isAjax, eventName, updateId, callInfo.RouteValueDictionary, cssClassNames, null /* htmlAttributes */);
        }
예제 #4
0
        public static MvcForm BeginJqueryForm(this AjaxHelper ajaxHelper, string formId, ActionResult actionResult, string eventName)
        {
            var callInfo = actionResult.AsMVCResult();

            return BeginJqueryForm(ajaxHelper, formId, callInfo.Action, callInfo.Controller, true, eventName, null, callInfo.RouteValueDictionary, "", null /* htmlAttributes */);
        }
예제 #5
0
        public static string UrlWithAction(this UrlHelper urlHelper, ActionResult controllerAction)
        {
            var callInfo = controllerAction.AsMVCResult();

            return urlHelper.Action(callInfo.Action, callInfo.Controller, callInfo.RouteValueDictionary);
        }