
我试图SelectList使用dropDown.setDataSource(result)事件将项目列表绑定到jquery中的Kendo下拉列表.但问题是,下拉列表中显示的数据显示为[object object].
$(document).ajaxStop(function () {
var exportTypeDropDown = $("#exportTypeDropDown").data("kendoDropDownList");
if (dropDownLoaded == false && exportTypeDropDown!=null) {
dropDownLoaded = true;
var url = "@Url.Action("GetExportTypes", UiControls.ControllerName)";
$.ajax({
url: url,
type: "POST",
traditional: true,
success: function (result) {
exportTypeDropDown.setDataSource(result);
}
});
}
});
Run Code Online (Sandbox Code Playgroud) 我试图根据索引将字符串转换为大写和小写.
我的字符串是一个LanguageCode喜欢cc-CC在那里cc是语言代码,CC是国家代码.用户可以输入任何格式,如"cC-Cc".我使用正则表达式来匹配数据是否是格式cc-CC.
var regex = new Regex("^[a-z]{2}-[A-Z]{2}$", RegexOptions.IgnoreCase);
//I can use CultureInfos from .net framework and compare it's valid or not.
//But the requirement is it should allow invalid language codes also as long
//The enterd code is cc-CC format
Run Code Online (Sandbox Code Playgroud)
现在,当用户输入的内容cC-Cc我正在尝试lowercase前两个字符,然后是uppercase最后两个字符.
我可以使用分割字符串-然后连接它们.
var languageDetails = languageCode.Split('-');
var languageCodeUpdated = $"{languageDetails[0].ToLowerInvariant()}-{languageDetails[1].ToUpperInvariant()}";
Run Code Online (Sandbox Code Playgroud)
我想我可以避免多个字符串创建,并相应地使用RegEx大写和小写.
在搜索相同内容时,我发现了一些使用的解决方案\L,\U但我无法将它们用作C#显示错误的编译器.此外,RegEx.Replace()还有一个 …