tags:

views:

172

answers:

2

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?

+1  A: 

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.

Justin Niessner
A: 

Is there no way to put class-Attributes to an .aspx Page (without codebehind)?

Beni