Hi I have declared an enum within the master page as
public enum AlertType
{
success = 1,
danger,
warning,
info,
primary,
secondary,
light,
dark
}
But when I tried to access one element of this enum inside my content page using string Name = this.Master.AlertType.danger.ToString();
it gives an error 'cannot reference a type through an expression'. What to do with this error? how can I access those values inside the enum here in my content page?
The problem is exactly what the error message says. You're using a local property this.Master.AlertType
to access an enum. This property has a value of its own (maybe success
) so it makes no sense to add .danger
to it.
Try
string Name = AlertType.danger.ToString();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.