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;
}
}
----------------------
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;
}
}
----------------------