View Single Post
  #5 (permalink)  
Old January 5th, 2012, 05:54 PM
jpjamie jpjamie is offline
Authorized User
Points: 313, Level: 6
Points: 313, Level: 6 Points: 313, Level: 6 Points: 313, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default

Quote:
Originally Posted by Imar View Post
Hi there,

If all your controls are number sequentially, you can set up a for loop:

Code:
 
for (int i = 0; i < 16; i++)
{
  if(Request["Q" + i.ToString() + "Comments"].Length > 200)
  {
    ModelState.AddError("Q" + i.ToString() + "Comments","Your comment cannot exceed 200 characters");
  }
}
Alternatively, you can set up an array of field names and loop over that.

Hope this helps,
Imar
Thanks Imar! Love this WebMatrix book!
Reply With Quote