Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 922611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:03:40+00:00 2026-05-15T19:03:40+00:00

I would like to create an attribute I can decorate specific fields or properties

  • 0

I would like to create an attribute I can decorate specific fields or properties with. This attribute will throw an exception if the field or property it decorates is null at a given point in an ASP.Net page lifecycle. I.E. if a property, “x”, is null at the prerender stage of an ASP.Net page, it will cause a “ArgumentNullException” exception to be throw with a nice message. Or a mean message. Either way, a message of my choosing.

Is this possible with standard .Net attributes, or would some kind of Spring.Net magic be required? Any guidance appreciated.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:03:41+00:00Added an answer on May 15, 2026 at 7:03 pm

    Now, I understand your setup. It’s just your actual question that confuses me.

    You would need to define your own attribute class, derived from the CLR Attribute class. It would just need a parameter indicating at which points to check.

    Then you would need a class derived from Page, which will be the base class for you pages, which, at the apprpriate time (e.g. PreRender() etc), it will use reflection to scan through the members of the page, looking for ones which have the attribute.

    UPDATE (responding to comments): The attributes are just data tacked onto the PropertyInfo. It’s never “executed” by the framework. You can look for it if you want, and if you find one of your attributes, you can call a method on it, but that has to be done by something outside of the attribute. (I know nothing about Spring, so I can’t help you there)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create an XSD that defines an attribute which can be
I would like to create this shape using just css. I am pretty sure
I would like to create an application which can learn to classify a sequence
I would like to create a calculated measure that sums up only a specific
I would like to create a custom action filter attribute that adds a value
I would like to create a DOM node, set the 'id' attribute and then
How can I create a custom property for my .Net assembly which would then
I would like to create a table that can store, say, the Title or
I have created Controller Attribute and would like to read SessionId but get error
i would like create a array of structure which have a dynamic array :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.