attributes

C# Use an attribute to handle exceptions in MVC

I want to handle exceptions thrown by any controller action with an ErrorView model and an error view. The idea was to have something like: [InformClientOfExceptions(typeof(MyErrorHandler))] public ActionResult MyAction(Int32 someId) { //...code } Then maybe have some class MyErrorHandler which implements a new interface IErrorVi...

AttributeError: 'module' object has no attribute 'printable'

I have this problem. Any idea? from OpenGL.raw.GLUT import * File "/usr/lib/python2.6/site-packages/OpenGL/raw/GLUT/__init__.py", line 6, in <module> from OpenGL.raw.GLUT.constants import * File "/usr/lib/python2.6/site-packages/OpenGL/raw/GLUT/constants.py", line 7, in <module> from OpenGL import platform, ...

Attribute to generate compilation error on method call ?

Hi, I would like to ensure that a method (actually a constructor in my case) is never called explicitly from code. It should only be called through reflection at runtime. To do that, I would like to apply an attribute on the method that would generate a compiler error if the method is called, something like : [NotCallable("This method ...

ASP.NET MVC 2 blog post seems to discuss nonexistent attributes

Reading this Brad Wilson blog post, I'm coming across several attributes (e.g., DisplayFormatString, EditFormatString, ShortDisplayName, SimpleDisplayText) that seem to have no available documentation, and I'm having no luck figuring out what namespace they belong to. Do these attributes even exist? Have they been replaced by different ...

Protected Configuration: useMachineContainer's default value?

In ASP.NET, when I'm using Protected Configuration, I'll specify something similar to the following in my web.config: <configuration> <configProtectedData defaultProvider="SampleProvider"> <providers> <add name="SampleProvider" type="System.Configuration.RsaProtectedConfigurationProvider, System.Confi...

How to "DRY up" C# attributes in Models and ViewModels?

This question was inspired by my struggles with ASP.NET MVC, but I think it applies to other situations as well. Let's say I have an ORM-generated Model and two ViewModels (one for a "details" view and one for an "edit" view): Model public class FooModel // ORM generated { public int Id { get; set; } public string FirstName { ...

Full Example XHTML document showing how to define additional attributes

I am trying to extend an xhtml document to allow extra attributes. In the w3.org it gives an example like so: <!ATTLIST a myattr CDATA #IMPLIED > See: 6.1. Defining additional attributes - http://www.w3.org/TR/1999/xhtml-modularization-19990406/developing.html#s_dev_attrs However i am not sure where to put that statemen...

Inheritance in Python

We just started learning about class inheritance and attribute lookup in python. I have a question about the following code: class a : n = 1 class b : n = 2 class c : n = 3 class d (a,b) : pass class e (d,c) : pass I know that e.n would equal 1 due to the nature of attribute lookup procedure (depth first search). However, how would I ...

RUby on Rails nested dynamic fields

Hi guys! I have a problem to find the right way to program dynamic fields. For example: I have two radio buttons and depending on how the user selects one radio button, it extends the form with different fields. Start form: - Radio button: car - Radio button: ship - Text field: name If the user clicks on the radio button "car" the for...

jquery function not working in Safari?

Is there something unique about Safari that would render the code below useless? While it works as expected in all the other browsers, it fails in Safari, insomuch that the attribute isn't removed at all... $('ul.nice-menu a').each(function() { $(this).removeAttr('title'); }); ...

Retrieving attributes from XML

Why does running this code... XmlDocument doc = new XmlDocument(); string xml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <BaaBaa> <BlackSheep HaveYouAny=""Wool"" /> </BaaBaa>"; doc.LoadXml(xml); XmlNodeList nodes = doc.SelectNodes("//BaaBaa"); fo...

xslt display attributes in specific order

Hello everyone, I was wondering if there is a way of displaying element's attributes in a specific order, with a use of sequence or somehow establishing an order rather than writing it explicitly. Sorry, explanation is a bit unclear. The example might help: So I have a template: <xsl:template match="Element/@1|@2|@3|@4"> <xsl:if ...

How can I read Database Tables with Attributes

Hi all, I want to read database tables with Attributes. I have Table in database and I have class same fields name. I want to transfer to my class which matched values in database using attributes. For Example : [ReadDBAttributes] public class News{ public string Title; public string Content; } How can i do? ...

XML schema for a complex type and I want an attribute on it.

In your xml wisdom, have you a idea on how to define the type for “bDead” to be? (type=”xs:Boolean”) <bDead>0 <xdn>state</xdn> <xdv>alive</xdv> </bDead> Here’s the schema. Where/how would I specify the type and ranges for bdead? I don’t think that I can.. <xs:element name="bDead" > <xs:complexType mixed="true"> <xs:sequence> ...

jquery: grab div title attr, put it into the image src

I'm creating a lightbox for a website i'm creating, no i don't want to use one already made, i want to make my own. when the user clicks on a somewhere on the website, i have jquery grab that 's title attribute, and stick it into an image src, and then inject that image tag into .overlay_content everything works except it wont grab th...

Jquery - having trouble pulling attr from image and applying to an element

i'm making a lightbox, i've followed tutorials just to get this far, and i'm so close. i'm having problems with this line: }).attr('src', 'imghref'); if i replace 'imghref' with 'images/watercolor.jpg' then it works fine, but i want 'imghref' to be the href of the link the user clicks on. my second problem, is that if i replace 'imgh...

Get member to which attribute was applied from inside attribute constructor?

Hi, I have a custom attribute, inside the constructor of my custom attribute I want to set the value of a property of my attribute to the type of the property my attribute was applied to, is there someway to access the member that the attribute was applied to from inside my attribute class? ...

How do input field methods (text_area, text_field, etc.) get attribute values from a record within a form_for block?

I have a standard Rails 2.3.5 app with a model called Post. Post has an attribute called url, and the following getter is defined: def url p = 'http://' u = self[:url] u.starts_with?(p) ? u : "#{p}#{u}" end If I load up script/console, I can do Post.first.url and get the desired result (e.g. it returns http://foo.com if the attr...

Can C# Attributes access the Target Class?

I want to access the properties of a class from the attribute class by using reflection. Is it possible? For example: class MyAttribute : Attribute { private void AccessTargetClass() { // Do some operations } } [MyAttribute] class TargetClass { } ...

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 ...