I have custom attribute called TestAttribute.
[AttributeUsage(AttributeTargets.All)]
public class TestAttribute: Attribute
{
IList<ComplexType> Template;
public TestAttribute(IList<ComplexType> _template)
{
Template = _template;
}
}
In my test.razor file I'm including that attribute.
@attribute [TestAttribute(myParam)]
myParam is defined in test.razor.cs file.
public IList<ComplexType> myParam = new List<ComplexType>(){
new ComplexType {Name = "1", type="A"},
new ComplexType {Name = "2", type="B"},
new ComplexType {Name = "3", type="A"},
};
But it gives the error object reference is required for the non-static field, method or property. Error pops from here -> @attribute [TestAttribute(myParam)]
How can I solve this issue?