Macho Matt
Macho Matt

Reputation: 1306

Add Attribute (System.Attribute variety) to .aspx page - not the code-behind

I am creating a custom Attribute (extending System.Attribute). I know I can put it on another class easily enough by doing the following.

[MattsAttribute]
public class SomeClassWhichIsACodeBehind { 

However, I need to be able to test this attribute easily, and putting it in the code-behind would cause a lot of extra effort to get it deployed to an environment which would respond to the behavior of attribute.

What I would like to do: declaratively apply this attribute to the .aspx page itself (which is really just another class that inherits from the code-behind). Is this possible? If so, what is the proper syntax for doing this?

Upvotes: 1

Views: 595

Answers (1)

Justin Niessner
Justin Niessner

Reputation: 245429

Check out this post from ScottGu:

http://weblogs.asp.net/scottgu/archive/2005/08/02/421405.aspx

You'll have to extend Page, but it looks about the closest you can come to doing what you want without putting something in a CodeBehind.

Upvotes: 1

Related Questions