我正在尝试使用所有动态元素创建级联下拉列表.
我的Html:
<select id="Sites" name="SelectedSiteId"><option value=""></option></select>
<select id="Sectors" name="SelectedSectorId"><option value=""></option></select>
Run Code Online (Sandbox Code Playgroud)
我有2个函数来使用ajax加载元素,两者都正常工作:
function GetSites() {
$.ajax({
url: '/Sites/GetSites',
dataType: "json",
type: "POST",
error: function () {
alert("An error ocurred.");
},
success: function (data) {
var items = "";
$.each(data, function (i, item) {
items += "<option value=\"" + item.Value + "\">" + item.Text + "</option>";
});
$("#Sites").html(items);
}
});
}
function GetSectors(siteId) {
$.ajax({
url: '/Sites/GetSectors',
data: { siteId: siteId },
dataType: "json",
type: "POST",
error: function () {
alert("An error …Run Code Online (Sandbox Code Playgroud) 我[Display(Name ="name")]在属性中有一个带有set 的类,并且[Table("tableName"]在类的顶部.
现在我正在使用反射来获取这个类的一些信息,我想知道我是否能以某种方式[Display(Name ="name")]向类本身添加一个.
它会是这样的
[Table("MyObjectTable")]
[Display(Name ="My Class Name")] <-------------- New Annotation
public class MyObject
{
[Required]
public int Id { get; set; }
[Display(Name="My Property Name")]
public string PropertyName{ get; set; }
}
Run Code Online (Sandbox Code Playgroud)