You must Sign In to post a response.
Category: ASP.Net MVC
#768742
Hai Sid,
First of all you need to get the class name and then you can iterate through the Attribute name with its value.
e.g.
You can also follow the below link for more details:
Hope it will be helpful to you.
Regards,
Pawan Awasthi(DNS MVM)
+91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
pawansoftit@gmail.com
First of all you need to get the class name and then you can iterate through the Attribute name with its value.
e.g.
var propertyName = typeof(ClassName).GetProperty(s);
var displayAttribute= propertyName.GetCustomAttribute(typeof(DisplayAttribute)) as DisplayAttribute;
if(displayAttribute!= null)
{
var name = displayAttribute.Name;
}
You can also follow the below link for more details:
http://stackoverflow.com/questions/14309255/mvc-access-display-name-attribute-in-the-controller
Hope it will be helpful to you.
Regards,
Pawan Awasthi(DNS MVM)
+91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
pawansoftit@gmail.com
#768746
namespace GP..Viewer.Controllers
{
[Authorize(Roles = ConfigurationManager.AppSettings["ViewerRole"])]
public class ViewerController : Controller
{
....
=> How do I read ViewerRole value in above code from config
{
[Authorize(Roles = ConfigurationManager.AppSettings["ViewerRole"])]
public class ViewerController : Controller
{
....
=> How do I read ViewerRole value in above code from config
Return to Return to Discussion Forum