本文整理汇总了C#中AjaxOptions.ToUnobtrusiveHtmlAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# AjaxOptions.ToUnobtrusiveHtmlAttributes方法的具体用法?C# AjaxOptions.ToUnobtrusiveHtmlAttributes怎么用?C# AjaxOptions.ToUnobtrusiveHtmlAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AjaxOptions
的用法示例。
在下文中一共展示了AjaxOptions.ToUnobtrusiveHtmlAttributes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToUnobtrusiveHtmlAttributesWithUpdateTargetIdAndExplicitInsertionMode
public void ToUnobtrusiveHtmlAttributesWithUpdateTargetIdAndExplicitInsertionMode()
{
// Arrange
AjaxOptions options = new AjaxOptions
{
InsertionMode = InsertionMode.InsertAfter,
UpdateTargetId = "someId"
};
// Act
var attributes = options.ToUnobtrusiveHtmlAttributes();
// Assert
Assert.Equal(3, attributes.Count);
Assert.Equal("true", attributes["data-ajax"]);
Assert.Equal("#someId", attributes["data-ajax-update"]);
Assert.Equal("after", attributes["data-ajax-mode"]);
}
示例2: ToUnobtrusiveHtmlAttributesEscapesClientSideIdentifiers
public void ToUnobtrusiveHtmlAttributesEscapesClientSideIdentifiers(string id, string expected)
{
// Arrange
AjaxOptions options = new AjaxOptions { UpdateTargetId = id, LoadingElementId = id };
// Act
var attributes = options.ToUnobtrusiveHtmlAttributes();
// Assert
Assert.Equal(expected, attributes["data-ajax-update"]);
Assert.Equal(expected, attributes["data-ajax-loading"]);
}
示例3: ToUnobtrusiveHtmlAttributesWithOnlyUpdateTargetId
public void ToUnobtrusiveHtmlAttributesWithOnlyUpdateTargetId()
{
// Arrange
AjaxOptions options = new AjaxOptions { UpdateTargetId = "someId" };
// Act
var attributes = options.ToUnobtrusiveHtmlAttributes();
// Assert
Assert.Equal(3, attributes.Count);
Assert.Equal("true", attributes["data-ajax"]);
Assert.Equal("#someId", attributes["data-ajax-update"]);
Assert.Equal("replace", attributes["data-ajax-mode"]); // Only added when UpdateTargetId is set
}
示例4: ToUnobtrusiveHtmlAttributesWithAllowCache
public void ToUnobtrusiveHtmlAttributesWithAllowCache()
{
// Arrange
AjaxOptions options = new AjaxOptions
{
UpdateTargetId = "someId",
HttpMethod = "GET",
AllowCache = true,
Url = "http://someurl.com",
OnComplete = "some_complete_function"
};
// Act
var attributes = options.ToUnobtrusiveHtmlAttributes();
// Assert
Assert.Equal(7, attributes.Count);
Assert.Equal("true", attributes["data-ajax"]);
Assert.Equal("GET", attributes["data-ajax-method"]);
Assert.Equal("http://someurl.com", attributes["data-ajax-url"]);
Assert.Equal("#someId", attributes["data-ajax-update"]);
Assert.Equal("true", attributes["data-ajax-cache"]);
Assert.Equal("replace", attributes["data-ajax-mode"]);
Assert.Equal("some_complete_function", attributes["data-ajax-complete"]);
}
示例5: ToUnobtrusiveHtmlAttributes
public void ToUnobtrusiveHtmlAttributes()
{
// Arrange
AjaxOptions options = new AjaxOptions
{
InsertionMode = InsertionMode.InsertBefore,
Confirm = "confirm",
HttpMethod = "POST",
LoadingElementId = "loadingElement",
LoadingElementDuration = 450,
UpdateTargetId = "someId",
Url = "http://someurl.com",
OnBegin = "some_begin_function",
OnComplete = "some_complete_function",
OnFailure = "some_failure_function",
OnSuccess = "some_success_function",
};
// Act
var attributes = options.ToUnobtrusiveHtmlAttributes();
// Assert
Assert.Equal(12, attributes.Count);
Assert.Equal("true", attributes["data-ajax"]);
Assert.Equal("confirm", attributes["data-ajax-confirm"]);
Assert.Equal("POST", attributes["data-ajax-method"]);
Assert.Equal("#loadingElement", attributes["data-ajax-loading"]);
Assert.Equal(450, attributes["data-ajax-loading-duration"]);
Assert.Equal("http://someurl.com", attributes["data-ajax-url"]);
Assert.Equal("#someId", attributes["data-ajax-update"]);
Assert.Equal("before", attributes["data-ajax-mode"]);
Assert.Equal("some_begin_function", attributes["data-ajax-begin"]);
Assert.Equal("some_complete_function", attributes["data-ajax-complete"]);
Assert.Equal("some_failure_function", attributes["data-ajax-failure"]);
Assert.Equal("some_success_function", attributes["data-ajax-success"]);
}
示例6: ToUnobtrusiveHtmlAttributesWithEmptyOptions
public void ToUnobtrusiveHtmlAttributesWithEmptyOptions()
{
// Arrange
AjaxOptions options = new AjaxOptions();
// Act
IDictionary<string, object> attributes = options.ToUnobtrusiveHtmlAttributes();
// Assert
Assert.Single(attributes);
Assert.Equal("true", attributes["data-ajax"]);
}