Questions tagged [custom-attributes]

In .NET Framework, custom attributes are user defined attributes which enable providing metadata for application elements such as assemblies, classes and methods.

In .NET Framework, custom attributes are user defined attributes which enable providing metadata for application elements such as assemblies, classes and methods.

1173 questions
-1
votes
1 answer

C# Generic add custom attributes properties

I have this Model: public class MobileKeyViewData { [Step(StepName="PersonalData")] public int PhoneNumber { get; set; } [Step(StepName="PersonalData")] public string Email { get; set; } [Step(StepName="Confirmation")] …
Fabio Santos
  • 253
  • 1
  • 4
  • 15
-1
votes
1 answer

How To Get All HTML Elements With A Specified Attribute Using JS?

I want to create a custom attribute for my project but I am not able to do so. I searched on Google but didn't get what I wanted. No data-* attributes, please... The attributes are the ones like they are in Vue.js or Angular.js This may seem like a…
Shardul Nalegave
  • 419
  • 9
  • 16
-1
votes
1 answer

Implementing security in mvc

We are trying to implement security in with our predefined set of permissions, which will serves the purpose whether to execute action method, show the view OR not, hide specific control(Like button,textbox etc) etc. So, while user getting logged in…
XamDev
  • 3,377
  • 12
  • 58
  • 97
-1
votes
1 answer

Way to hit multiple attributes in c#

After this: Custom Attribute not being hit I'm looking for way to hit method's attributes in my application. Currently as I know if there's some custom attribute like [AttributeUsage(AttributeTargets.All)] public class MyAttribute : Attribute { …
Roni
  • 369
  • 1
  • 7
  • 22
-1
votes
1 answer

Is there an Attribute to indicate required C# compiler/feature version?

I have a method that has code that depends on c# 6.0. (The 6.0 new features are cool BTW!) My co-workers may open it with an older version and be confused by the compile error or think it's a typo or syntax error. I don't want them wasting time, and…
toddmo
  • 20,682
  • 14
  • 97
  • 107
-1
votes
1 answer

Change WCF custom attributes by code

first of all, I want to be clear : I don't know that much on WCF attributes and I'm there to learn about it. Here is the context : we have a project where we have different forms. Each form contains datas. Some datas are different and some are the…
Forceex
  • 3
  • 1
-1
votes
1 answer

Create a custom attribute that restricts attribute to n number of strings

I am working in VisualStudio with a Product object from a model. I am very unfamiliar with custom attributes. I would like to restrict a Product's name, for example, to 3 words maximum. [Required (ErrorMessage="Product name is required.")] …
andres
  • 301
  • 6
  • 21
-1
votes
1 answer

Creating Attribute Aliases?

I'm trying to create a generic layer between the frameworks I am using and my application's code and have been blocked by a framework's need to decorate my classes with attributes. Is there a way to be able to somehow map attributes to other…
-1
votes
1 answer

Phone code prefix number mvc custom validaton

I have followed different examples to come up with a custom validator to check a phone number. My number is going into three different fields. I just want to make sure that if the phone number is provided then all three fields should have some thing…
learning...
  • 3,104
  • 10
  • 58
  • 96
-1
votes
1 answer

C# attribute doesnt apply to method

I have the following C# code class Program { [My] static void Main(string[] args) { SomeMethod(); } [My] static void SomeMethod() { Console.WriteLine("1111"); } } public class MyAttribute:…
-1
votes
1 answer

Get custom attribute value using Next() by Class

I'm looking to get the value of a custom attribute in an image by class, using next(). $("#chkSell").live('change',function(){ var posType = $(this).next('img[class="qtyImgDD"]').attr('posType'); });
Nick G
  • 1,209
  • 8
  • 34
  • 58
-1
votes
1 answer

How to fetch products in magento by product's attribute

I need to create a new view template file for products filtered by a custom attribute set as "purpose". So far so good, I have a template file that list products by visibility:
Gilberto Albino
  • 2,572
  • 8
  • 38
  • 50
-1
votes
1 answer

Modelstate.Isvalid showing false

I have made a web application in MVC Razor. When I post/submit the page DATA ANNOTATION validation fires on those fields also which was hidden/or not shown to user. As dataannodation [Required] validation are put on hidden properties also, I am…
user2028367
-2
votes
3 answers

C# - Is it possible? - [DescriptionAttribute()] with TextBox text

Can a DescriptionAttribute in an enumeration contain a TextBox'es text? I ask because I have a file with numerous TextBoxes and I was hoping to match the content of them with a value that I have. I doubt I can do this, but I'm not sure at…
user646265
  • 1,011
  • 3
  • 14
  • 32
-2
votes
1 answer

c# conditional Required Attribute

how can i to put conditional Required Attribute into class? i tried the following code and it doesn't work. public partial class Zone { [RequireCondition ] public int LastCount { get; set; } } public class RequireCondition :…
user3835327
  • 1,194
  • 1
  • 14
  • 44
1 2 3
78
79