// Summary:
        //     Represents support for ASP.NET AJAX within an ASP.NET MVC application.

        #region ActionLink
        // Summary:
        //     Returns an anchor element that contains the URL to the specified action method;
        //     when the action link is clicked, the action method is invoked asynchronously
        //     by using JavaScript.
        //
        // Parameters:
        //   ajaxHelper:
        //     The AJAX helper.
        //
        //   linkText:
        //     The inner text of the anchor element.
        //
        //   actionName:
        //     The name of the action method.
        //
        //   ajaxOptions:
        //     An object that provides options for the asynchronous request.
        //
        // Returns:
        //     An anchor element.
        //
        // Exceptions:
        //   System.ArgumentException:
        //     The linkText parameter is null or empty.
        //public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, AjaxOptions ajaxOptions);
        //
        // Summary:
        //     Returns an anchor element that contains the URL to the specified action method;
        //     when the action link is clicked, the action method is invoked asynchronously
        //     by using JavaScript.
        //
        // Parameters:
        //   ajaxHelper:
        //     The AJAX helper.
        //
        //   linkText:
        //     The inner text of the anchor element.
        //
        //   actionName:
        //     The name of the action method.
        //
        //   routeValues:
        //     An object that contains the parameters for a route. The parameters are retrieved
        //     through reflection by examining the properties of the object. This object
        //     is typically created by using object initializer syntax.
        //
        //   ajaxOptions:
        //     An object that provides options for the asynchronous request.
        //
        // Returns:
        //     An anchor element.
        //
        // Exceptions:
        //   System.ArgumentException:
        //     The linkText parameter is null or empty.
        //public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, object routeValues, AjaxOptions ajaxOptions);
        //
        // Summary:
        //     Returns an anchor element that contains the URL to the specified action method;
        //     when the action link is clicked, the action method is invoked asynchronously
        //     by using JavaScript.
        //
        // Parameters:
        //   ajaxHelper:
        //     The AJAX helper.
        //
        //   linkText:
        //     The inner text of the anchor element.
        //
        //   actionName:
        //     The name of the action method.
        //
        //   routeValues:
        //     An object that contains the parameters for a route.
        //
        //   ajaxOptions:
        //     An object that provides options for the asynchronous request.
        //
        // Returns:
        //     An anchor element.
        //
        // Exceptions:
        //   System.ArgumentException:
        //     The linkText parameter is null or empty.
        //public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions);
        //
        // Summary:
        //     Returns an anchor element that contains the URL to the specified action method;
        //     when the action link is clicked, the action method is invoked asynchronously
        //     by using JavaScript.
        //
        // Parameters:
        //   ajaxHelper:
        //     The AJAX helper.
        //
        //   linkText:
        //     The inner text of the anchor element.
        //
        //   actionName:
        //     The name of the action method.
        //
        //   controllerName:
        //     The name of the controller.
        //
        //   ajaxOptions:
        //     An object that provides options for the asynchronous request.
        //
        // Returns:
        //     An anchor element.
        //
        // Exceptions:
        //   System.ArgumentException:
        //     The linkText parameter is null or empty.
        //public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, AjaxOptions ajaxOptions);
        //
        // Summary:
        //     Returns an anchor element that contains the URL to the specified action method;
        //     when the action link is clicked, the action method is invoked asynchronously
        //     by using JavaScript.
        //
        // Parameters:
        //   ajaxHelper:
        //     The AJAX helper.
        //
        //   linkText:
        //     The inner text of the anchor element.
        //
        //   actionName:
        //     The name of the action method.
        //
        //   routeValues:
        //     An object that contains the parameters for a route. The parameters are retrieved
        //     through reflection by examining the properties of the object. This object
        //     is typically created by using object initializer syntax.
        //
        //   ajaxOptions:
        //     An object that provides options for the asynchronous request.
        //
        //   htmlAttributes:
        //     An object that contains the HTML attributes to set for the element.
        //
        // Returns:
        //     An anchor element.
        //
        // Exceptions:
        //   System.ArgumentException:
        //     The linkText parameter is null or empty.
        //public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes);
        //
        // Summary:
        //     Returns an anchor element that contains the URL to the specified action method;
        //     when the action link is clicked, the action method is invoked asynchronously
        //     by using JavaScript.
        //
        // Parameters:
        //   ajaxHelper:
        //     The AJAX helper.
        //
        //   linkText:
        //     The inner text of the anchor element.
        //
        //   actionName:
        //     The name of the action method.
        //
        //   routeValues:
        //     An object that contains the parameters for a route.
        //
        //   ajaxOptions:
        //     An object that provides options for the asynchronous request.
        //
        //   htmlAttributes:
        //     An object that contains the HTML attributes to set for the element.
        //
        // Returns:
        //     An anchor element.
        //
        // Exceptions:
        //   System.ArgumentException:
        //     The linkText parameter is null or empty.
        //public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes);
        //
        // Summary:
        //     Returns an anchor element that contains the URL to the specified action method;
        //     when the action link is clicked, the action method is invoked asynchronously
        //     by using JavaScript.
        //
        // Parameters:
        //   ajaxHelper:
        //     The AJAX helper.
        //
        //   linkText:
        //     The inner text of the anchor element.
        //
        //   actionName:
        //     The name of the action method.
        //
        //   controllerName:
        //     The name of the controller.
        //
        //   routeValues:
        //     An object that contains the parameters for a route. The parameters are retrieved
        //     through reflection by examining the properties of the object. This object
        //     is typically created by using object initializer syntax.
        //
        //   ajaxOptions:
        //     An object that provides options for the asynchronous request.
        //
        // Returns:
        //     An anchor element.
        //
        // Exceptions:
        //   System.ArgumentException:
        //     The linkText parameter is null or empty.
        //public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions);
        //
        // Summary:
        //     Returns an anchor element that contains the URL to the specified action method;
        //     when the action link is clicked, the action method is invoked asynchronously
        //     by using JavaScript.
        //
        // Parameters:
        //   ajaxHelper:
        //     The AJAX helper.
        //
        //   linkText:
        //     The inner text of the anchor element.
        //
        //   actionName:
        //     The name of the action method.
        //
        //   controllerName:
        //     The name of the controller.
        //
        //   routeValues:
        //     An object that contains the parameters for a route.
        //
        //   ajaxOptions:
        //     An object that provides options for the asynchronous request.
        //
        // Returns:
        //     An anchor element.
        //
        // Exceptions:
        //   System.ArgumentException:
        //     The linkText parameter is null or empty.
        //public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions);
        //
        // Summary:
        //     Returns an anchor element that contains the URL to the specified action method;
        //     when the action link is clicked, the action method is invoked asynchronously
        //     by using JavaScript.
        //
        // Parameters:
        //   ajaxHelper:
        //     The AJAX helper.
        //
        //   linkText:
        //     The inner text of the anchor element.
        //
        //   actionName:
        //     The name of the action method.
        //
        //   controllerName:
        //     The name of the controller.
        //
        //   routeValues:
        //     An object that contains the parameters for a route. The parameters are retrieved
        //     through reflection by examining the properties of the object. This object
        //     is typically created by using object initializer syntax.
        //
        //   ajaxOptions:
        //     An object that provides options for the asynchronous request.
        //
        //   htmlAttributes:
        //     An object that contains the HTML attributes to set for the element.
        //
        // Returns:
        //     An anchor element.
        //
        // Exceptions:
        //   System.ArgumentException:
        //     The linkText parameter is null or empty.
        //public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes);
        //
        // Summary:
        //     Returns an anchor element that contains the URL to the specified action method;
        //     when the action link is clicked, the action method is invoked asynchronously
        //     by using JavaScript.
        //
        // Parameters:
        //   ajaxHelper:
        //     The AJAX helper.
        //
        //   linkText:
        //     The inner text of the anchor element.
        //
        //   actionName:
        //     The name of the action method.
        //
        //   controllerName:
        //     The name of the controller.
        //
        //   routeValues:
        //     An object that contains the parameters for a route.
        //
        //   ajaxOptions:
        //     An object that provides options for the asynchronous request.
        //
        //   htmlAttributes:
        //     An object that contains the HTML attributes to set for the element.
        //
        // Returns:
        //     An anchor element.
        //
        // Exceptions:
        //   System.ArgumentException:
        //     The linkText parameter is null or empty.
        //public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes);
        //
        // Summary:
        //     Returns an anchor element that contains the URL to the specified action method;
        //     when the action link is clicked, the action method is invoked asynchronously
        //     by using JavaScript.
        //
        // Parameters:
        //   ajaxHelper:
        //     The AJAX helper.
        //
        //   linkText:
        //     The inner text of the anchor element.
        //
        //   actionName:
        //     The name of the action method.
        //
        //   controllerName:
        //     The name of the controller.
        //
        //   protocol:
        //     The protocol for the URL, such as "http" or "https".
        //
        //   hostName:
        //     The host name for the URL.
        //
        //   fragment:
        //     The URL fragment name (the anchor name).
        //
        //   routeValues:
        //     An object that contains the parameters for a route. The parameters are retrieved
        //     through reflection by examining the properties of the object. This object
        //     is typically created by using object initializer syntax.
        //
        //   ajaxOptions:
        //     An object that provides options for the asynchronous request.
        //
        //   htmlAttributes:
        //     An object that contains the HTML attributes to set for the element.
        //
        // Returns:
        //     An anchor element.
        //
        // Exceptions:
        //   System.ArgumentException:
        //     The linkText parameter is null or empty.
        //public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes);
        //
        // Summary:
        //     Returns an anchor element that contains the URL to the specified action method;
        //     when the action link is clicked, the action method is invoked asynchronously
        //     by using JavaScript.
        //
        // Parameters:
        //   ajaxHelper:
        //     The AJAX helper.
        //
        //   linkText:
        //     The inner text of the anchor element.
        //
        //   actionName:
        //     The name of the action method.
        //
        //   controllerName:
        //     The name of the controller.
        //
        //   protocol:
        //     The protocol for the URL, such as "http" or "https".
        //
        //   hostName:
        //     The host name for the URL.
        //
        //   fragment:
        //     The URL fragment name (the anchor name).
        //
        //   routeValues:
        //     An object that contains the parameters for a route.
        //
        //   ajaxOptions:
        //     An object that provides options for the asynchronous request.
        //
        //   htmlAttributes:
        //     An object that contains the HTML attributes to set for the element.
        //
        // Returns:
        //     An anchor element.
        //
        // Exceptions:
        //   System.ArgumentException:
        //     The linkText parameter is null or empty.
        //public static MvcHtmlString ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes);

        public static MvcHtmlString ActionLinkImage(this AjaxHelper ajaxHelper, string urlImage, string linkText, string actionName, object routeValues, AjaxOptions ajaxOptions)
        {
            String        mvc = AjaxExtensions.ActionLink(ajaxHelper, linkText, actionName, ajaxOptions).ToHtmlString();
            StringBuilder sb  = new StringBuilder("", HelperBaseExtensions.Capacity);

            sb.Append(mvc.Substring(0, mvc.LastIndexOf(linkText)));
            sb.Append(String.Format("<img src='{0}'/>", urlImage));
            sb.Append("</a>");

            return(MvcHtmlString.Create(sb.ToString()));
        }
Beispiel #2
0
 /// <summary>
 /// 返回一个非注入式Ajax链接
 /// </summary>
 /// <param name="ajaxHelper"></param>
 /// <param name="linkText">链接文字</param>
 /// <param name="actionName">动作名</param>
 /// <param name="controllerName">控制器名</param>
 /// <param name="areaName">区域名</param>
 /// <param name="htmlAttributes">html特性</param>
 /// <param name="ajaxOptions">Ajax参数</param>
 public static MvcHtmlString AsiatekActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string controllerName, string areaName, object htmlAttributes, AjaxOptions ajaxOptions)
 {
     return(AjaxExtensions.ActionLink(ajaxHelper, linkText, actionName, controllerName, new { area = areaName }, ajaxOptions, htmlAttributes));
 }
        public static MvcHtmlString Sayfalama(this AjaxHelper helper, int SayfaNo, int ToplamKayit,
                                              string ActionName, int SayfaGosterim = 3, string HedefDiv = "icerik")
        {
            if (ToplamKayit >= SayfaGosterim)
            {
                AjaxOptions ao = new AjaxOptions();
                ao.UpdateTargetId   = HedefDiv;
                ao.LoadingElementId = "progress";

                StringBuilder sb = new StringBuilder();
                int           ToplamSayfaSayisi = 0;
                object        ilkYaz            = "";
                object        geriYaz           = "";
                object        ileriYaz          = "";
                object        sonYaz            = "";

                if (ToplamKayit % SayfaGosterim == 0)
                {
                    ToplamSayfaSayisi = ToplamKayit / SayfaGosterim;
                }
                else
                {
                    ToplamSayfaSayisi = ToplamKayit / SayfaGosterim + 1;
                }


                #region Sayfa 10 Adet Gösterme
                int ilkGosterim = SayfaNo;
                int sonGosterim = SayfaNo;

                if (ToplamSayfaSayisi - 1 == SayfaNo)
                {
                    ilkGosterim = ilkGosterim - 9;
                }

                else if (ToplamSayfaSayisi - 2 == SayfaNo)
                {
                    ilkGosterim = ilkGosterim - 8;
                }

                else if (ToplamSayfaSayisi - 3 == SayfaNo)
                {
                    ilkGosterim = ilkGosterim - 7;
                }

                else if (ToplamSayfaSayisi - 4 == SayfaNo)
                {
                    ilkGosterim = ilkGosterim - 6;
                }

                else
                {
                    ilkGosterim = ilkGosterim - 5;
                }


                switch (sonGosterim)
                {
                case 0: sonGosterim = 10; break;

                case 1: sonGosterim = 10; break;

                case 2: sonGosterim = 10; break;

                case 3: sonGosterim = 10; break;

                case 4: sonGosterim = 10; break;

                default: sonGosterim = sonGosterim + 5; break;
                }

                #endregion

                #region İlk Sayfa ve En son Sayfa İşlemi

                if (!(ToplamSayfaSayisi <= 10))
                {
                    if (SayfaNo == ToplamSayfaSayisi - 1)
                    {
                        sonYaz = "<span class='Last Page' > Son Sayfa </span>\n";
                    }
                    else
                    {
                        sonYaz = AjaxExtensions.ActionLink(helper, "Son Sayfa", ActionName, new { Sayfa = ToplamSayfaSayisi - 1 }, ao, new { @class = "Last Page" });
                    }


                    if (SayfaNo == 0)
                    {
                        ilkYaz = "<span class='First Page' > İlk Sayfa </span>\n";
                    }
                    else
                    {
                        ilkYaz = AjaxExtensions.ActionLink(helper, "İlk Sayfa", ActionName, new { Sayfa = 0 }, ao, new { @class = "First Page" });
                    }
                }
                #endregion


                for (int i = 0; i < ToplamSayfaSayisi; i++)
                {
                    if (i >= ilkGosterim && i < sonGosterim)
                    {
                        if (i == SayfaNo)
                        {
                            sb.Append("<a class='current' >" + (i + 1) + "</a>\n");
                        }
                        else
                        {
                            sb.Append(AjaxExtensions.ActionLink(helper, Convert.ToString((i + 1)), ActionName, new { Sayfa = (i) }, ao, new { @class = "number" }));
                        }
                    }
                }

                #region Sayfa İleri Geri İşlemi
                SayfaNo = SayfaNo + 1;
                int geri = SayfaNo - 2;

                if (geri < 0)
                {
                    geriYaz = "<span class='Previous Page' > « Geri </span>\n";
                }
                else
                {
                    geriYaz = AjaxExtensions.ActionLink(helper, "« Geri", ActionName, new { Sayfa = geri }, ao, new { @class = "Previous Page" });
                }

                if (SayfaNo >= ToplamSayfaSayisi)
                {
                    ileriYaz = "<span class='Next Page' > İleri » </span>\n";
                }
                else
                {
                    ileriYaz = AjaxExtensions.ActionLink(helper, "İleri »", ActionName, new { Sayfa = SayfaNo }, ao, new { @class = "Next Page" });
                }

                #endregion

                string toplamMetin = "<div class='pageTotal' > Toplam: " + ToplamKayit.ToString() + "</div>";

                return(MvcHtmlString.Create(ilkYaz.ToString() + geriYaz.ToString() + sb.ToString() + ileriYaz.ToString() + sonYaz.ToString() + toplamMetin));
            }
            else
            {
                return(MvcHtmlString.Create(""));
            }
        }