Click here to Skip to main content
15,896,529 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I wanted to know is there a way to have a Validator to fire if the number entered is higher or Lower than 20% of the number auto populated in the TextBox?
Posted
Comments
José Amílcar Casimiro 14-Nov-13 11:31am    
Extend an existing one.
Computer Wiz99 14-Nov-13 11:32am    
What do you mean?
José Amílcar Casimiro 14-Nov-13 11:37am    
You can extend the RangeValidator control into a new control for your validation needs.
Computer Wiz99 14-Nov-13 11:42am    
Ok. Can you show me how? I never did that before What will it look like on the .aspx source page?
José Amílcar Casimiro 14-Nov-13 11:46am    
http://stackoverflow.com/questions/251842/asp-net-extended-range-validation

1 solution

This is what you are looking for : http://msdn.microsoft.com/en-us/library/f70d09xt(v=vs.85).aspx[^]. You can even set Maximum and Minimum values at server side [.cs file].
C#
Range1.MaximumValue=....//Calculate the value you want and apply it here 
 
Share this answer
 
v2
Comments
Computer Wiz99 14-Nov-13 11:52am    
Rohan Leuva, Thanks for the link but the validator needs to validate between last year number and this year number. It will be different for each user. The number being compared to is auto populated from a database. Will that still work?
Thanks7872 14-Nov-13 12:03pm    
Thats why i mentioned that you can set the Min and Max values at server side code also. Get required values from database,perform calculation and as a result e.g. you get 15,if you want to check that it should be between 10 to 15 then you will set like this:

Range1.MinimumValue="10";
Range1.MaximumValue="15";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900