0

Most of the times we have requirements of adding different client side validations on the web pages and the easiest way to achieve this in ASP.Net is to use the existing set of validator controls.

In SharePoint when we design custom webparts which takes some data as input, we might need to add some client side validations using ASP.Net validator controls, but there are a few things that always need to be taken care of while using ASP.Net validator controls within SharePoint custom webparts.

1. Within a webpart we might have more than one control triggering server side postbacks. In this case the validator controls will validate with each and every postback, but the actual need might be to only validate the form with a single postback event, let's say through the "SUBMIT" button. To avoid this, one need to set the CausesValidation property to false for all those controls causing server side postabacks where you do not want the form to get validated.

e.g. CausesValidation="false"

Thanks,
Suryakant
SharePoint Migration Experts India

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by suryakantb
0

If you want to use asp.net validation system with the SharePoint’s DateTimeControl, the first thing you need to know is that this control is “just” a wrapper around simple ASP.NET controls (textbox, dropdownlist).

If you want to set the ControlToValidate property of an ASP.NET validator to the DateTimeControl’s ID, it will throw an error!
As you can guess, you have to target the controls inside the DateTimeControl.

Since the DateTimeControl set the name of the controls programmatically, you can retrieve the id of the control:

Textbox date: DateTimeControl.ID +”Date”
Dropdownlist hours: DateTimeControl.ID +”DateHours”
Dropdownlist minutes: DateTimeControl.ID +”DateMinutes”

Read this blog for more information: http://www.sambeauvois.be/blog/2010/03/use-asp-net-validators-with-the-sharepointdatetimecontrol/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.