Help with custom attributes

G

Guest

I'm having trouble getting custom attributes to work properly. When I copy
and paste the tutorial from the documentation into a console app, it works
fine. The following code in a web form, however, doesn't seem to call the
attribute's constructor at all, for any of the attributes whether class or
method. What am I doing wrong? Placing a breakpoint on the constructor's
assignment to the local variable shows that it doesn't get called.

-----------------------------------------

[SomeDumb("asdf")]
public class test : System.Web.UI.Page {

[SomeDumb("asdf")]
public test() {
}

[SomeDumb("asdf")]
private void Page_Load(object sender, System.EventArgs e) {
DoStuff();
}

[SomeDumb("asdf")]
public void DoStuff() {
return;
}

#region Web Form Designer generated code
//snip
#endregion
}

public class SomeDumbAttribute: System.Attribute {

public string _SomeDumb;

public SomeDumbAttribute( string SomeDumb ) {
this._SomeDumb = SomeDumb;
}

}

----------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top