custom-attributes

Why would one want to use AttributeUsage AllowMultiple when creating attributes ?

Hi, According to a book I'm reading, the AllowMultiple public property of AttributeUsage specifies: "...whether the target can have multiple instances of the attribute applied to it." Why would I want/not want to use this ? Thanks, Scott ...

Error while using RequireHttps of MVC

I am using RequireHttps for my application to redirect t0 https when the user enters http by default. I have followed asp-net-mvc-requirehttps-in-production-only But after implementing this, i am getting the following error for each request: System.Web.HttpException: A public action method 'blank.htm' was not found on controller 'MyPro...

.NET, C#: How to add a custom serialization attribute that acts as ISerializable interface

I am doing some serialization of db linq objects, which contain EntitySet and EntityRef classes. I found a pretty easy way to deal with serialization of these classes, by simply using ISerializable to properly handle members of this type (converting them to lists for serialization, and undoing it on deserialization). However, it would ...

Displaying custom product attributes based on customer group (Magento)

I have wholesale attributes for certain products under one store in Magento. I would like to set it so those particular attributes only appear on the product page IF the customer is logged in and they are in the Wholesale customer group. Is this possible? ...

Correct way for custom HTML attributes

I am writing custom form validation javascript library and I am thinking about correct markup syntax. Let's say I have an input that requires number between 1 000 and 10 000. So far, I came up with something like this: <input class='validate required number' min='1000' max='10000' /> Is this correct way to do it? I have two problems ...

C# add custom attributes for a parent's property in an inherited class

Hi, I'm displaying Business Object in generic DataGrids, and I want to set the column header through a custom attribute, like: class TestBo { [Header("NoDisp")] public int ID {get; set;} [Header("Object's name")] public String Name { get; set; } } So far, so good, but I'd also want to separate my display from my dat...

.NET custom property attribute?

EDIT: I'd better rephrase: How can I shift the GET-implementation of a Class property to a / using a custom attribute? (I've added instantation vars (classname, propertyname) to the attribute, however I'd rather have these automatically fetched ofcourse.) Public Class CustomClass <CustomAttributeClass(ClassName:="CustomClass", Prope...

Are Custom Attributes OK in XHTML

Hi Guys I understand that according to the HTML specification, it's invalid to add custom attributes to elements. Is this also invalid with XHTML? I thought XHTML was part of the XML family, and as such was extensible. Being extensible, isn't it ok to use custom attributes? Dave ...

How to Create A Document Type Definition

Hi Guys I've been creating a lot of my own custom attributes in my XHTML documents lately, and am aware that because they are custom attributes, they won't validate against the W3C standard. Isn't it true that I can specify my own DTD to make it validate? If so, can anyone tell me what's involved in doing this in an ASP.NET MVC app? T...

Why should I prepend my custom attributes with "data-"?

So any custom data attribute that I use should start with "data-": <li class="user" data-name="John Resig" data-city="Boston" data-lang="js" data-food="Bacon"> <b>John says:</b> <span>Hello, how are you?</span> </li> Will anything bad happen if I just ignore this? I.e.: <li class="user" name="John Resig" city="Boston" lan...

Accessing wrapped method attribute in C#

I have following code: public static void ProcessStep(Action action) { //do something here if (Attribute.IsDefined(action.Method, typeof(LogAttribute))) { //do something here [1] } action(); //do something here } For easy use I have some similar methods using method above. For example: public static vo...

CodeDOM: Adding DebuggerStepThroughAttribute to property

I know how to add a DebuggerStepThroughAttribute to a method or a constructor, usually you add it to the CustomAttributes collection of a code member. But I don't see a way to do this for the setter and getter of a C# property, because neither of them provides this collection where you add the attributes. Does anyone have a clue? ...

.net Attributes that handle exceptions - usage on a property accessor

Hi, well I know from my asp.net mvc experience that you can have attributes that handle exceptions (HandleErrorAttribute). As far as I can tell the Controller class has some OnException event which may be integral to this behaviour. However, I want to do something similar in my own code: dream example: public String MyProperty { ...

StructureMap with my own attributes in C#

Hi All, I have an attribute that I have written that has a dependency on the Data Access Layer so I made a constructor that took the DAL class as a parameter (marked with [DefaultConstructor] and another, blank, constructor that is parameterless. When I call a method that depends on the attribute how do I make StructureMap inject the co...

Custom IIdentity and passing data from an attribute to a controller

Here's my scenario: I've successfully created a custom IIdentity that I pass to a GenericPrincipal. When I access that IIdentity in my controller I have to cast the IIdentity in order to use the custom properties. example: public ActionResult Test() { MyCustomIdentity identity = (MyCustomIdentity)User.Identity; int userID = ide...

Storage model for various user setting and attributes in database?

I'm currently trying to upgrade a user management system for one web application. This web application is used to provide remote access to various networking equipment for educational purposes. All equipment is assigned to various pods, which users can book for periods of time. The current system is very simple - just 2 user types: admi...

Identifying all types with some attribute

Hello SO; I have an issue with .Net reflection. The concept is fairly new to me and I'm exploring it with some test cases to see what works and what doesn't. I'm constructing an example wherein I populate a set of menus dynamically by scanning through my Types' attributes. Basically, I want to find every type in my main namespace that ...

Generate multiple attribute?

ATM i cant quiet imagine how this will work. I'm sure it can be done. I notice a pattern use in my attribute where i always use 3 specific attributes together. Take the below as an example [MyAttr(4, @"a"), MyAttr(41, "b"), MyAttr(45, "ab")] Mine is much more complicated but i would like to define one attribute with more...

Jquery: Create hidden attributes? I need to reduce tag bulkyness.

I'm sure we've all done this before: <a id="232" rel="link_to_user" name="user_details" class="list hoverable clickable selectable"> USER #232 </a> But then we say, oh my, I need more ways to store tracking info about this div! <a id="232-343-22" rel="link_to_user:fotomeshed" name="user_details" class="groupcolor-45 elements-698 list...

How do I read an attribute on a class at runtime?

I am trying to create a generic method that will read an attribute on a class and return that value at runtime. How do would I do this? Note: DomainName attribute is of class DomainNameAttribute. [DomainName(“MyTable”)] Public class MyClass : DomianBase {} What I am trying to generate: //This should return “MyTable” String Doma...