Hello,
I have a custom application page and am using for the list forms. I have used SharePoint:TextField and SharePoint:SaveButton with control mode of controls so that I do not need to write any code for saving, getting or updating field values.
I also have some required site columns used in the list and when I save the form without entering values, it throws an exception automatically as it is already defined as a required field.
Now my requirement is I have one SharePoint:TextField on the page which I need to validate based on the other SharePoint:BooleanField. So I have added SharePoint:InputFormCustomValidator to the <div> where SharePoint:TextField is defined which I need to validate. I have also written on server validate method on the page code behind. I have overridden save handler with SPContext.Current.FormContext.OnSaveHandler += new EventHandler(mySaveHandler) and handling page.Validate method and using SaveButton.SaveItem(SPContext.Current, false, ""); to handle save event.
But the problem is while opening up the form, it throws an error and while digging in ULD log, it says System.Web.HttpException: Unable to find control id 'ID of my SharePoint:TextField' referenced by the 'ControlToValidate' property of 'MyCustomValidator'.
Any pointers would be very helpful. I also tried setting ID generated after rendering the page like ctl00_PlaceholderMain_.. stuff but that also does not help. How to validate SharePoint:TextField with SharePoint:InputFormCustomValidator? Or let me know if there is any other technique or way that I can use here. I do not want to go with jQuery as I want to show proper validation messages in validation summary along with built in required field validation messages.