CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 11/18/2005 10:02:58 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 7 Views: 17 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
8 Items, 1 Pages 1 |< << Go >> >|
BorekBernard
Asp.Net User
Is there any attribute to indicate required property?11/18/2005 10:02:58 PM

0/0

I'm curious if there is some attribute to indicate that some control's property is mandatory.

Imagine I'm a developer of a BaseValidator class which has ControlToValidate property. This property should never be left blank so I'd appreciate some RequiredPropertyAttribute class to denote this obligation. Compiler then could check if this property is present and set and otherwise raise an error.

Is there something to accomplish this?

Thanks, Borek


Borek Bernard, http://borber.com
PLBlum
Asp.Net User
Re: Is there any attribute to indicate required property?11/19/2005 4:36:20 PM

0/0

Me too (both developing validators and wanting an attribute to demand that it is required). Unfortunately, there is no attribute as requested. In my validators, when there is a required field that is not setup, I through an exception in the OnPreRender method to describe the problem.
--- Peter Blum
Creator of Professional Validation And More Suite, Peter's Date Package, and Peter's Polling Package
www.PeterBlum.com
BorekBernard
Asp.Net User
Re: Is there any attribute to indicate required property?11/21/2005 12:58:03 PM

0/0

 PLBlum wrote:
Unfortunately, there is no attribute as requested.


I made a suggestion through product feedback center. You can vote for it here.

Borek Bernard, http://borber.com
PLBlum
Asp.Net User
Re: Is there any attribute to indicate required property?11/21/2005 5:37:03 PM

0/0

Great, Borek. I have voted for it.
--- Peter Blum
Creator of Professional Validation And More Suite, Peter's Date Package, and Peter's Polling Package
www.PeterBlum.com
Eilon
Asp.Net User
Re: Is there any attribute to indicate required property?11/21/2005 11:39:09 PM

0/0

The only way to guarantee that the property is set, is exactly what was previously suggested: Throw an exception at runtime (and yes, PreRender is a great place to do that).

One way to help guide users who are using your control is to use the ASP.net 2.0 / VS2005 feature called Smart Tasks. It's a great way to place common and/or important tasks right near your control so that the user won't be searching through the property grid to find two or three important properties out of 50. Here's a sample that I wrote recently:

http://www.leftslipper.com/ShowFaq.aspx?FaqId=7

Thanks,
Eilon
Blog: http://weblogs.asp.net/LeftSlipper/
BorekBernard
Asp.Net User
Re: Is there any attribute to indicate required property?11/26/2005 8:44:46 PM

0/0

 Eilon wrote:
The only way to guarantee that the property is set, is exactly what was previously suggested: Throw an exception at runtime (and yes, PreRender is a great place to do that).


Can you please elaborate why is PreRender so great place to do that? Why not do it in Init stage of page life cycle? (that's what I would do).

Thank you.

Borek Bernard, http://borber.com
Eilon
Asp.Net User
Re: Is there any attribute to indicate required property?11/26/2005 11:53:31 PM

0/0

The reason for PreRender is that it happens after pretty much "everything else" happened. By that I mean that the page developer no longer has any practical events to handle to do interesting stuff, and other controls are done collecting their data. From PreRender and on the only things that happen are typically: building control trees, registering script/styles, and finally rendering.

Let's say you threw the exception in Init, then this scenario would be broken (and it's a fairly standard scenario):

<script runat="server">
   void Page_Load() {
      MyControl1.RequiredProperty = "Some Value";
   }
</script>
...
<foo:MyControl runat="server" id="MyControl1" />

By the time Page_Load happens and I want to set the required property, the control would have already thrown an exception and it would be too late. Lots of interactions happen up until PreRender so you typically want to give people as much chance as possible to set stuff up.

Thanks,
Eilon

Blog: http://weblogs.asp.net/LeftSlipper/
BorekBernard
Asp.Net User
Re: Is there any attribute to indicate required property?11/27/2005 12:10:25 AM

0/0

Thanks for the answer. I realized all you've writter just a minute after I posted my question but I haven't written about it because I knew that your answer will be quicker than my post approval :) (yes, I'm one of those lucky moderated guys :)

Borek Bernard, http://borber.com
8 Items, 1 Pages 1 |< << Go >> >|


Search This Site:






Books:
Pro .NET 1.1 Remoting, Reflection, and Threading: From Professional to Expert Authors: Syed Fahad Gilani, Tobin Titus, Mike Gillespie, Fabio Claudio Ferracchiati, David Curran, James Hart, Benny K. Mathew, Sandra Gopikrishna, Andy Olsen, Tejaswi Redkar, Robin Pars, Jon Pinnock, Srinivasa Sivakumar, Pages: 647, Published: 2005
Beginning VB 2008: From Novice to Professional Authors: Christian Gross, Pages: 450, Published: 2008
.NET and XML Authors: Niel M. Bornstein, Pages: 455, Published: 2003

Web:
Web Slice Format Specification - Version 0.9 Web publishers can use this format in conjunction with properties from hAtom ... Optional; Uses the rel name feedurl; The href attribute indicates the Web ...
Custom Attributes in C#, Part I - Basics There are four sections of any custom attribute AttributeUsage, ... A value of ' true' for AllowMultiple property indicates whether multiple instances of the ...
Strawman simpler syntax for RDF An rdf:extend attribute on any element indicates that the semantics of the element ... Other tags are assumed to be property elements if there is subject ...
Atlas Control Toolkit and the DefaultValue attribute - Glavs Blog May 20, 2006 ... You can specify the properties that your extender uses, and you can specify a DefaultValue attribute to indicate what the default value of a ...
OpenDS - Member Virtual Attribute Required, Yes. Admin Action Required, None. Advanced Property ... real-overrides -virtual - Indicates that any real values contained in the entry are ...
Connector business object requirements Note: When specified for a required attribute, cardinality 1 indicates a ... The Required property specifies whether an attribute must contain a value. ...
VB.NET Language in a Nutshell, 2nd Edition: Chapter 8: Attributes Any required arguments must correspond to those expected by one of the .... to each attribute, as well as an additional Bugs property that indicates whether ...
The Objective-C 2.0 Programming Language: Property Declaration and ... You can decorate a property with attributes by using the form @property( attribute [ .... Note that neither is required for any given @property declaration. ...
Datatypes for Web Distributed Authoring and Versioning (WebDAV ... The server should indicate successful detection and parsing of the typed value by setting the xsi:type attribute on the property element in the response ...
VOA - Publications - CTR(E) IA 111202 Data Quantity / Quality ... The property attribute data to be collected includes most of the current ten-box ... BA Reference Numbers are available if required. Any request for more ...

Videos:
Zeitgeist 2 : Addendum - Subtitles English / French Zeitgeist: Addendum, by Peter Joseph 2008 English Subtitles ! French See ya later on thezeitgeistmovement.com You can Download Srt file here : EN:...
www.moldytoaster.com vowed themselves to slow starvation before they would admit an ear of wheat from Poland or Egypt, vote for a sliding-scale or no scale at all, as th...
Long Beach Special Workshop Meeting Long Beach Special Workshop Meeting











 
All Times Are GMT