關於在MVC中view中設置默認值,可以象如下設置:
1、關於VIEWMODEL的部分
如果是C# 6.0,
public class Test{
public int X { get; set; } = 100;
public string Y { get; set; } = "test";
}
如果語法不支持,只能改回.net 2.0的寫法。
public class UserType
{
private int _UserType = 1;
public int UserTypeID
{
get
{
return this._UserType;
}
set
{
this._UserType = value;
}
}
}