本文整理汇总了C#中AjaxOptions类的典型用法代码示例。如果您正苦于以下问题:C# AjaxOptions类的具体用法?C# AjaxOptions怎么用?C# AjaxOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AjaxOptions类属于命名空间,在下文中一共展示了AjaxOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSuccessProperty
public void OnSuccessProperty() {
// Arrange
AjaxOptions options = new AjaxOptions();
// Act & Assert
MemberHelper.TestStringProperty(options, "OnSuccess", String.Empty, false, true);
}
示例2: InsertionModeProperty
public void InsertionModeProperty() {
// Arrange
AjaxOptions options = new AjaxOptions();
// Act & Assert
MemberHelper.TestEnumProperty(options, "InsertionMode", InsertionMode.Replace, false);
}
示例3: OnFailureProperty
public void OnFailureProperty() {
// Arrange
AjaxOptions options = new AjaxOptions();
// Act & Assert
MemberHelper.TestStringProperty(options, "OnFailure", String.Empty);
}
示例4: HttpMethodProperty
public void HttpMethodProperty() {
// Arrange
AjaxOptions options = new AjaxOptions();
// Act & Assert
MemberHelper.TestStringProperty(options, "HttpMethod", String.Empty, false, true);
}
示例5: InsertionModePropertyExceptionText
public void InsertionModePropertyExceptionText()
{
// Arrange
AjaxOptions options = new AjaxOptions();
// Act & Assert
Assert.ThrowsArgumentOutOfRange(
delegate { options.InsertionMode = (InsertionMode)4; },
"value",
@"Specified argument was out of the range of valid values.");
}
示例6: InsertionModeUnobtrusiveTests
public void InsertionModeUnobtrusiveTests(InsertionMode mode, string expected)
{
// Arrange
AjaxOptions options = new AjaxOptions { InsertionMode = mode };
// Act
string result = options.InsertionModeUnobtrusive;
// Assert
Assert.Equal(expected, result);
}
示例7: ActionLinkAnonymousValues
public void ActionLinkAnonymousValues() {
// Arrange
AjaxHelper helper = GetAjaxHelper();
object values = new { controller = "Controller" };
AjaxOptions options = new AjaxOptions { UpdateTargetId = "update-div" };
// Act
string actionLink = helper.ActionLink("Some Text", "Action", values, options);
// Assert
Assert.AreEqual(@"<a href=""" + HtmlHelperTest.AppPathModifier + @"/app/Controller/Action"" onclick=""Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: 'update-div' });"">Some Text</a>", actionLink);
}
示例8: InsertionModePropertyExceptionText
public void InsertionModePropertyExceptionText() {
// Arrange
AjaxOptions options = new AjaxOptions();
// Act & Assert
ExceptionHelper.ExpectArgumentOutOfRangeException(
delegate {
options.InsertionMode = (InsertionMode)4;
},
"value",
"The value '4' is outside the valid range of the enumeration type 'System.Web.Mvc.Ajax.InsertionMode'.\r\nParameter name: value");
}
示例9: InsertionModePropertyExceptionText
public void InsertionModePropertyExceptionText() {
// Arrange
AjaxOptions options = new AjaxOptions();
// Act & Assert
ExceptionHelper.ExpectArgumentOutOfRangeException(
delegate {
options.InsertionMode = (InsertionMode)4;
},
"value",
@"Specified argument was out of the range of valid values.
Parameter name: value");
}
示例10: DisposeWritesClosingFormTag
public void DisposeWritesClosingFormTag() {
// Arrange
AjaxHelper ajaxHelper = GetAjaxHelper();
AjaxOptions ajaxOptions = new AjaxOptions { UpdateTargetId = "some-id" };
StringWriter writer = new StringWriter();
ajaxHelper.ViewContext.Writer = writer;
// Act
IDisposable form = ajaxHelper.BeginForm("Action", "Controller", ajaxOptions);
form.Dispose();
// Assert
Assert.IsTrue(writer.ToString().EndsWith("</form>"));
}
示例11: PagerBuilder
public PagerBuilder(HtmlHelper htmlHelper, AjaxHelper ajaxHelper, String actionName, String controllerName, int noOfPages, int pageIndex, PagerOptions pagerOptions, String routeName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<String, object> htmlAttributes)
{
_msAjaxPaging = (default(AjaxHelper) != ajaxHelper);
if (actionName.IsNullOrEmpty())
{
actionName = _msAjaxPaging
? (String) ajaxHelper.ViewContext.RouteData.Values["action"]
: (String) htmlHelper.ViewContext.RouteData.Values["action"];
}
if (controllerName.IsNullOrEmpty())
{
controllerName = _msAjaxPaging
? (String) ajaxHelper.ViewContext.RouteData.Values["controller"]
: (String) htmlHelper.ViewContext.RouteData.Values["controller"];
}
if (null == pagerOptions) pagerOptions = new PagerOptions();
_htmlHelper = htmlHelper;
_ajaxHelper = ajaxHelper;
_actionName = actionName;
_controllerName = controllerName;
_NoOfPages = noOfPages;
_pageIndex = pageIndex;
_pagerOptions = pagerOptions;
_routeName = routeName;
_routeValues = routeValues;
_ajaxOptions = ajaxOptions;
_htmlAttributes = htmlAttributes;
// start page index
_startPageIndex = pageIndex - (pagerOptions.NumericPagerItemCount / 2);
if (_startPageIndex + pagerOptions.NumericPagerItemCount > _NoOfPages)
_startPageIndex = _NoOfPages + 1 - pagerOptions.NumericPagerItemCount;
if (_startPageIndex < 1) _startPageIndex = 1;
// end page index
_endPageIndex = _startPageIndex + _pagerOptions.NumericPagerItemCount - 1;
if (_endPageIndex > _NoOfPages) _endPageIndex = _NoOfPages;
}
示例12: DisposeWritesClosingFormTag
public void DisposeWritesClosingFormTag() {
// Arrange
Mock<HttpResponseBase> mockResponse = new Mock<HttpResponseBase>(MockBehavior.Strict);
AjaxHelper ajaxHelper = GetAjaxHelper(mockResponse);
AjaxOptions ajaxOptions = new AjaxOptions { UpdateTargetId = "some-id" };
// Arrange expectations
mockResponse.Expect(response => response.Write(AjaxFormWithTargetId)).Verifiable();
mockResponse.Expect(response => response.Write(AjaxFormClose)).Verifiable();
// Act
IDisposable form = ajaxHelper.BeginForm("Action", "Controller", ajaxOptions);
form.Dispose();
// Assert
mockResponse.Verify();
}
示例13: BeginRouteFormTypedValues_Unobtrusive
public void BeginRouteFormTypedValues_Unobtrusive()
{
// Arrange
AjaxHelper ajaxHelper = GetAjaxHelper(unobtrusiveJavaScript: true);
AjaxOptions ajaxOptions = new AjaxOptions();
RouteValueDictionary values = new RouteValueDictionary();
StringWriter writer = new StringWriter();
ajaxHelper.ViewContext.Writer = writer;
// Act
IDisposable form = ajaxHelper.BeginRouteForm("namedroute", values, ajaxOptions);
// Assert
Assert.Equal(@"<form action=""" + MvcHelper.AppPathModifier + @"/app/named/home/oldaction"" data-ajax=""true"" method=""post"">", writer.ToString());
}
示例14: RouteLinkNamedRouteTypedValuesAndAttributes
public void RouteLinkNamedRouteTypedValuesAndAttributes() {
// Arrange
AjaxHelper ajaxHelper = GetAjaxHelper();
RouteValueDictionary values = new RouteValueDictionary {
{ "controller", "Controller" },
{ "action", "Action" }
};
Dictionary<string, object> htmlAttributes = new Dictionary<string, object> { { "foo", "bar" }, { "baz", "quux" } };
AjaxOptions options = new AjaxOptions { UpdateTargetId = "update-div" };
// Act
string actionLink = ajaxHelper.RouteLink("Some Text", "namedroute", values, options, htmlAttributes);
// Assert
Assert.AreEqual(@"<a baz=""quux"" foo=""bar"" href=""" + HtmlHelperTest.AppPathModifier + @"/app/named/Controller/Action"" onclick=""Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: 'update-div' });"">Some Text</a>", actionLink);
}
示例15: RouteLinkWithHostName
public void RouteLinkWithHostName() {
// Arrange
AjaxHelper ajaxHelper = GetAjaxHelper();
Dictionary<string, object> htmlAttributes = new Dictionary<string, object> { { "foo", "bar" }, { "baz", "quux" } };
AjaxOptions options = new AjaxOptions { UpdateTargetId = "update-div" };
// Act
string actionLink = ajaxHelper.RouteLink("Some Text", "namedroute", null, "baz.bar.foo", null, null, options, htmlAttributes);
// Assert
Assert.AreEqual(@"<a baz=""quux"" foo=""bar"" href=""http://baz.bar.foo" + HtmlHelperTest.AppPathModifier + @"/app/named/home/oldaction"" onclick=""Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: 'update-div' });"">Some Text</a>", actionLink);
}