Example #1
0
 public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, Task <ActionResult> taskResult, AjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes)
 {
     return(ajaxHelper.RouteLink(linkText, routeName, taskResult.Result, ajaxOptions, htmlAttributes));
 }
Example #2
0
 public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, ActionResult result, AjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes)
 {
     return(ajaxHelper.RouteLink(linkText, result.GetRouteValueDictionary(), ajaxOptions, htmlAttributes));
 }
Example #3
0
 public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, Task <ActionResult> taskResult, AjaxOptions ajaxOptions, object htmlAttributes)
 {
     return(ajaxHelper.RouteLink(linkText, routeName, taskResult.Result, ajaxOptions, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)));
 }
Example #4
0
 public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, Task <ActionResult> taskResult, AjaxOptions ajaxOptions)
 {
     return(ajaxHelper.RouteLink(linkText, routeName, taskResult.Result, ajaxOptions, null));
 }
Example #5
0
 public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, ActionResult result, AjaxOptions ajaxOptions, object htmlAttributes)
 {
     return(ajaxHelper.RouteLink(linkText, result.GetRouteValueDictionary(), ajaxOptions, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)));
 }
Example #6
0
        String GenerateAnchor(PagerItem item)
        {
            if (_msAjaxPaging)
            {
                var routeValues = GetCurrentRouteValues(_ajaxHelper.ViewContext);
                if (item.PageIndex == 0)
                {
                    routeValues[_pagerOptions.PageIndexParameterName] = ScriptPageIndexName;
                }
                else
                {
                    routeValues[_pagerOptions.PageIndexParameterName] = item.PageIndex;
                }

                return(_routeName.IsNullOrEmpty()
                        ? _ajaxHelper.RouteLink(item.Text, routeValues, _ajaxOptions).ToString()
                        : _ajaxHelper.RouteLink(item.Text, _routeName, routeValues, _ajaxOptions).ToString());
            }

            var url = GenerateUrl(item.PageIndex);

            if (_pagerOptions.UseJqueryAjax)
            {
                var ehBuilder = new StringBuilder();
                //ignore OnSuccess property
                if (_ajaxOptions.OnFailure.IsNotNullOrEmpty() || _ajaxOptions.OnBegin.IsNotNullOrEmpty())
                {
                    ehBuilder.Append("$.ajax({url:$(this).attr(\'href\'),success:function(data,status,xhr){$(\'#");
                    ehBuilder.Append(_ajaxOptions.UpdateTargetId).Append("\').html(data);}");
                    if (_ajaxOptions.OnFailure.IsNotNullOrEmpty())
                    {
                        ehBuilder.Append(",error:").Append(HttpUtility.HtmlAttributeEncode(_ajaxOptions.OnFailure));
                    }
                    if (_ajaxOptions.OnBegin.IsNotNullOrEmpty())
                    {
                        ehBuilder.Append(",beforeSend:").Append(HttpUtility.HtmlAttributeEncode(_ajaxOptions.OnBegin));
                    }
                    if (_ajaxOptions.OnComplete.IsNotNullOrEmpty())
                    {
                        ehBuilder.Append(",complete:").Append(HttpUtility.HtmlAttributeEncode(_ajaxOptions.OnComplete));
                    }
                    ehBuilder.Append("});return false;");
                }
                else
                {
                    ehBuilder.Append("$(\'#").Append(_ajaxOptions.UpdateTargetId);
                    ehBuilder.Append("\').load($(this).attr(\'href\')");
                    if (_ajaxOptions.OnComplete.IsNotNullOrEmpty())
                    {
                        ehBuilder.Append(",").Append(HttpUtility.HtmlAttributeEncode(_ajaxOptions.OnComplete));
                    }
                    ehBuilder.Append(");return false;");
                }

                return(url.IsNullOrEmpty()
                           ? _htmlHelper.Encode(item.Text)
                           : String.Format(CultureInfo.InvariantCulture,
                                           "<a href=\"{0}\" onclick=\"{1}\">{2}</a>",
                                           GenerateUrl(item.PageIndex), ehBuilder, item.Text));
            }

            return(String.Format("<a href=\"{0}\" onclick=\"{1}\"></a>",
                                 url, "window.open(this.attributes.getNamedItem('href').value,'_self')"));
        }
Example #7
0
 public static string ActionLink(this AjaxHelper ajaxHelper, string linkText, ActionResult result, AjaxOptions ajaxOptions)
 {
     return(ajaxHelper.RouteLink(linkText, result.GetRouteValueDictionary(), ajaxOptions));
 }