Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use of Rules.Parital.cs Question
Message
From
03/01/2011 11:28:43
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01494437
Message ID:
01494439
Views:
48
>Need to implement forcing of upper case on certain fields on aspx web pages. After much googling, it appears there is simply no existing format string I could put in the DisplayFormat that will both display data entered as upper and force the underlying value to upper. Most of the solutions I found involved javascript and other kludges I am not interested in.
>
>This is solution I am trying, but I have concerns whether this is kosher in the underlying MM.NET framework. Please comment.
>
>1. On the ASPX weg page, you can declare more than one CSS style, as follows. Not the two classes, one displays color code for readwrite enabled fields on a screen, the second forces sting value to display as upper case.
>
>
><mm:mmTextBox ID="txtAmateurCertFinal" runat="server" BindingSource="SaProspects" 
>            CssClass="TextBox-ReadWrite UpperCase" Width="33px" 
>               BindingSourceMember="AMATEURCERTFINAL" ></mm:mmTextBox>
>
>
>2. In the bizobjRules.Partial.cs, for each attribute I want to apply an action to, this:
>
>
>
>	public partial class SaProspectsRules
>	{
>		public override void CheckExtendedRulesHook<EntityType>(EntityType currentEntity)
>		{
>			SaProspectsEntity Entity = currentEntity as SaProspectsEntity;
>			
>			// Call Validation methods
>
>            Entity.AMATEURCERTFINAL = Entity.AMATEURCERTFINAL.ToUpper();
>
>		}
>
>
>I just tried this, and it works. After saving the data from the form with a this.Save() MM.NET command, I walk through the code, it hits the above rule, and applies it, and the upper cased value is written back to the database record.
>
>So what is the question? I am sort of assuming obviously that the rules are applied on a record by record basis as each record is processed, in case there could ever be multiples in the entity being saved??
>
>This seems like a really logical way to put this conversion of the data where it belongs, in a business object, not in the web page.
>
>Thanks,
>
>Ronald D. Edge
>Director of Information Services
>Indiana University Athletics
>1001 East 17th St Bloomington , IN 47408
>edge@indiana.edu


If it is a business rule to store the value in upper case then using the business rule to do that is fine. I would however move that to a rule called ValidateAmateurCertFinal and call that from the CheckExtendedRules hook method. As to the display part, the value would always display as upper case if they are stored as upper case until they edit the value. Then it would display as they typed it. If your CSS fixes that, then you should be fine with what you did. Javascript would be the only other way I would know of.
Tim
Timothy Bryan
Previous
Reply
Map
View

Click here to load this message in the networking platform