本文整理汇总了C#中System.Web.Mvc.Ajax.AjaxOptions类的典型用法代码示例。如果您正苦于以下问题:C# AjaxOptions类的具体用法?C# AjaxOptions怎么用?C# AjaxOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AjaxOptions类属于System.Web.Mvc.Ajax命名空间,在下文中一共展示了AjaxOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RawActionLink
// using timjames' approach
public static MvcHtmlString RawActionLink(this AjaxHelper ajaxHelper, string rawHtml, string action, string controller, AjaxOptions ajaxOptions, object routeValues = null, object htmlAttributes = null)
{
string linkText = Guid.NewGuid().ToString();
string originalActionLink = ajaxHelper.ActionLink(linkText, action, controller, routeValues, ajaxOptions, htmlAttributes).ToString();
return MvcHtmlString.Create(originalActionLink.Replace(linkText, rawHtml));
}
示例2: AjaxPager
public static MvcHtmlString AjaxPager(this HtmlHelper html, IPagedList pagedList, PagerOptions pagerOptions, AjaxOptions ajaxOptions)
{
if (pagedList == null)
return AjaxPager(html, pagerOptions, null);
return AjaxPager(html, pagedList.TotalItemCount, pagedList.PageSize, pagedList.CurrentPageIndex, null, null, null, pagerOptions, null, ajaxOptions,
null);
}
示例3: ActionLinkTo
/// <summary>
/// Метод создает ссылку, которая с помощью Ajax запроса загружает в контейнер с именем main
/// требуемый PartialView
/// </summary>
public static MvcHtmlString ActionLinkTo(this AjaxHelper ajaxHelper, String linkText, String actionName, String controllerName = null, Object routeValues = null, String areaName = null, String loadMessage = null, Object htmlAttributes = null)
{
// Создаем маршрут
RouteValueDictionary routeValueDictionary = routeValues == null ? new RouteValueDictionary() : (RouteValueDictionary)(routeValues);
if (!String.IsNullOrEmpty(actionName) && !routeValueDictionary.ContainsKey("action"))
routeValueDictionary.Add("action", actionName);
if (!String.IsNullOrEmpty(controllerName) && !routeValueDictionary.ContainsKey("controller"))
routeValueDictionary.Add("controller", controllerName);
if (!routeValueDictionary.ContainsKey("area")) {
if (!String.IsNullOrEmpty(areaName))
routeValueDictionary.Add("area", areaName);
else
routeValueDictionary.Add("area", "");
}
// Создаем параметры Ajax
AjaxOptions ajaxOptions = new AjaxOptions() {
UpdateTargetId = "main",
InsertionMode = InsertionMode.Replace,
HttpMethod = "POST",
LoadingElementId = "loadLayout",
OnBegin = "changeLoadMesage('" + loadMessage + "')",
OnSuccess = "onPageLoaded()"
};
RouteValueDictionary htmlatr = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
htmlatr.Add("onclick", "return ajaxClick(this);");
// Возвращаем строку
String ajaxActionName = "Ajax" + actionName;
return ajaxHelper.ActionLink(linkText, ajaxActionName, null, routeValueDictionary, ajaxOptions, htmlatr);
}
示例4: InputActionLink
public static IHtmlString InputActionLink(this AjaxHelper ajaxHelper, ActionResult result, AjaxOptions ajaxOptions)
{
var builder = new TagBuilder("input");
var link = ajaxHelper.ActionLink("[replaceme]", result, ajaxOptions);
var mvcLink = new MvcHtmlString(link.ToHtmlString().Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing)));
return mvcLink;
}
示例5: PagingNavigator
public static MvcHtmlString PagingNavigator(this AjaxHelper helper, int pageNum, int itemsCount, int pageSize)
{
StringBuilder sb = new StringBuilder();
AjaxOptions ao = new AjaxOptions {UpdateTargetId = "BooksDiv"};
if (pageNum > 0)
{
sb.Append(helper.ActionLink("<", "Index","Books", new { pageNum = pageNum - 1 },ao));
}
else
{
sb.Append(HttpUtility.HtmlEncode("<"));
}
sb.Append(" ");
int pagesCount = (int)Math.Ceiling((double)itemsCount / pageSize);
if (pageNum < pagesCount - 1)
{
sb.Append(helper.ActionLink(">", "Index","Books", new { pageNum = pageNum + 1 },ao));
}
else
{
sb.Append(HttpUtility.HtmlEncode(">"));
}
return MvcHtmlString.Create(sb.ToString());
}
示例6: ActionLink
public static string ActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName,
RouteValueDictionary routeValues, AjaxOptions ajaxOptions,
IDictionary<string, object> htmlAttributes)
{
return ActionLink(ajaxHelper, linkText, actionName, null /* controllerName */, routeValues, ajaxOptions,
htmlAttributes);
}
示例7: SortableColumnHeader
public static string SortableColumnHeader(this AjaxHelper helper, HtmlHelper htmlHelper, TicketCenterListSettings currentDisplayPreferences, string action, string listName, string sortColumn, string linkText, AjaxOptions ajaxOptions)
{
var imgContent = string.Empty;
var linkContent = linkText;
var indexContent = string.Empty;
var sortColumns = currentDisplayPreferences.SortColumns;
var cColumn = sortColumns.SingleOrDefault(sc => sc.ColumnName == sortColumn);
if (cColumn != null)
{
var uh = new UrlHelper(helper.ViewContext.RequestContext);
string imgSrc = uh.Content((cColumn.SortDirection == ColumnSortDirection.Ascending) ? "~/Content/arrow_top.png" : "~/Content/arrow_down.png");
imgContent = string.Format("<img src='{0}' alt='{1}' />", imgSrc, cColumn.SortDirection.ToString());
var idx = sortColumns.IndexOf(cColumn) + 1;
indexContent = string.Format("<sup>[{0}]</sup>",idx.ToString());
}
StringBuilder sb = new StringBuilder();
sb.AppendLine("<span style='white-space:nowrap;'>");
var lLine = helper.ActionLink(linkContent, "SortList", new { ListName = listName, ColumnName = sortColumn }, ajaxOptions, new { OnMouseDown = "setShiftStatus(event);", Title = "[shift+click] to add or remove columns from the sort" }).ToString();
sb.AppendLine(lLine + indexContent);
sb.AppendLine(imgContent);
sb.AppendLine("</span>");
return sb.ToString();
}
示例8: ImageActionLink
public static MvcHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, string altText, string actionName,
string controllerName, object routeValues, AjaxOptions ajaxOptions,
object htmlAttributes)
{
return ComposeImageActionLink(helper, imageUrl, altText, actionName, controllerName, routeValues, ajaxOptions,
htmlAttributes);
}
示例9: IconActionLink
public static MvcHtmlString IconActionLink(this AjaxHelper helper, string icon, string linkText, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes)
{
var builder = new TagBuilder("span");
builder.MergeAttribute("class", icon);
var link = helper.ActionLink("[replaceme] " + linkText, actionName, controllerName, routeValues, ajaxOptions, htmlAttributes).ToHtmlString();
return new MvcHtmlString(link.Replace("[replaceme]", builder.ToString()));
}
示例10: GenerateAjaxScript
private static string GenerateAjaxScript(AjaxOptions ajaxOptions, string scriptFormat)
{
var ajaxOptionsHelper = new AjaxOptionsHelper(ajaxOptions);
string optionsString = ajaxOptionsHelper.ToJavascriptString();
return String.Format(CultureInfo.InvariantCulture, scriptFormat, optionsString);
}
示例11: PagerBuilder
internal PagerBuilder(AjaxHelper helper, string actionName, string controllerName, int totalPageCount, int pageIndex, PagerOptions options, AjaxOptions ajaxOptions, object values)
{
// Set defaults
if (String.IsNullOrEmpty(actionName))
actionName = (string)helper.ViewContext.RouteData.Values["action"];
if (String.IsNullOrEmpty(controllerName))
controllerName = (string)helper.ViewContext.RouteData.Values["controller"];
if (options == null)
options = new PagerOptions();
// Assign to fields
_helper = helper;
_actionName = actionName;
_controllerName = controllerName;
_totalPageCount = totalPageCount;
_pageIndex = pageIndex;
_options = options;
_values = values;
_ajaxOptions = ajaxOptions;
// Calculate start page index
_startPageIndex = pageIndex - (options.MaximumPageNumbers / 2);
if (_startPageIndex + options.MaximumPageNumbers > _totalPageCount)
_startPageIndex = _totalPageCount - options.MaximumPageNumbers;
if (_startPageIndex < 0)
_startPageIndex = 0;
// Calculate end page index
_endPageIndex = _startPageIndex + _options.MaximumPageNumbers;
if (_endPageIndex > _totalPageCount)
_endPageIndex = _totalPageCount;
}
示例12: BeginPostForm
public static MvcForm BeginPostForm(this AjaxHelper ajaxHelper,
string url, object routeValues, string beginCallback,
string successCallback, string failureCallback, string validationCallback, object htmlAttributes)
{
MvcForm retVal = null;
beginCallback = HandledNullOrEmptyCallbacks(beginCallback);
successCallback = HandledNullOrEmptyCallbacks(successCallback);
failureCallback = HandledNullOrEmptyCallbacks(failureCallback);
validationCallback = HandledNullOrEmptyCallbacks(validationCallback);
AjaxOptions ajaxOptions = new AjaxOptions()
{
Url = url,
HttpMethod = "POST",
OnBegin = beginCallback,
OnSuccess = CommonFormSubmitSuccessCallback.Replace(
SuccessCallbackPlaceholder, successCallback).Replace(
FailureCallbackPlaceholder, failureCallback).Replace(ValidationCallbackPlaceholder, validationCallback),
OnFailure = CommonFormSubmitFailureCallback
};
retVal = ajaxHelper.BeginForm(string.Empty, routeValues, ajaxOptions, htmlAttributes);
return retVal;
}
示例13: RawAjaxActionLink
public static MvcHtmlString RawAjaxActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName,
string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes)
{
var repId = Guid.NewGuid().ToString();
var lnk = ajaxHelper.ActionLink(repId, actionName, controllerName, routeValues, ajaxOptions, htmlAttributes);
return MvcHtmlString.Create(lnk.ToString().Replace(repId, linkText));
}
示例14: DisplayNameForSort
public static IHtmlString DisplayNameForSort(this AjaxHelper helper, string displayName, string columName, string actionName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, string controllerName = null)
{
if (!string.IsNullOrWhiteSpace(columName))
{
string orderBy;
string iconName;
HtmlHelperExtensions.GetListOrderParams(columName, out orderBy, out iconName);
if (routeValues.ContainsKey("orderBy"))
{
routeValues["orderBy"] = orderBy;
}
else
{
routeValues.Add("orderBy", orderBy);
}
MvcHtmlString link;
if (string.IsNullOrEmpty(controllerName))
{
link = helper.ActionLink(displayName, actionName, routeValues, ajaxOptions);
}
else
{
link = helper.ActionLink(displayName, actionName, controllerName, routeValues, ajaxOptions);
}
string htmlStr = "<div class=\"ap-sortedHeader\">{0}<i class=\"ap-sortedHeader fa {1}\"></i></div>";
return new MvcHtmlString(string.Format(htmlStr, link.ToString(), iconName));
}
else
{
return new MvcHtmlString(displayName);
}
}
示例15: PagingRouteValue
public PagingRouteValue(string actionName, string controllerName, object optionValues = null, AjaxOptions ajaxOption = null, string prefix = "") : this()
{
this.ActionName = actionName;
this.ControllerName = controllerName;
this.AjaxOptions = ajaxOption;
this.OptionValues = optionValues;
this.RouteValuePrefix = prefix;
}