验证自定义共享点字段是否为空?
我正在使用 Sharepoint 2010 .. 以及 Visual Studio 2010 中的自定义字段。
我创建了一个自定义字段。这个特定的字段是日期时间字段(“终止日期”)。如果它为空且另一个字段(“合同终止”等于 yes ),我希望它验证失败。
所以我之前用计算字段做过这个。这有效,但它将验证错误放在编辑表单的顶部,而不是我想要的“终止日期”字段旁边。就像在自定义字段中使用 GetValidatedString 验证字段失败时通常会出现的情况一样。
因为它位于错误的位置,所以我创建了一个自定义字段。但由于日期为空,因此它永远不会命中 GetValidatedString 方法。我错过了什么吗?如果“终止日期”字段为空,是否有另一种方法可以使其验证失败并位于“终止日期”字段旁边?
我也尝试使用事件接收器解决方案..问题在于它还会将错误消息放在顶部..而不是“终止日期”字段旁边。
建议?
I'm using Sharepoint 2010 .. with a custom field in visual studio 2010.
I created a custom field. This particular one is a datetime field ("Termination Date"). I want it to fail validation if it is blank and another field ( "Contract Terminates" is equal to yes ).
So I had previously did this with a calculated field. And that works but it puts the validation error at the top of the edit form, not next to the "Termination Date" field where I want it.. like it would normally be if the field failed validation using GetValidatedString in a custom field.
So because it's in the wrong place, I made a custom field. But because the date is blank, it never hits GetValidatedString method. Am I missing something? is there another way to have it fail validation and be next to the 'Termination Date' field if the 'Termination Date' field is blank?
I'm tried using an event receiver solution also.. the problem there is that it would also put the error message on the top.. not next to the Termination Date field.
Suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于自定义字段,您可以覆盖 FieldRenderingControl,编写您自己的 FieldControl。如果您不在“行踪”列表中使用此自定义字段,您可以从 DateTimeField 继承字段控件 并覆盖 Validate 方法例如:
For custom field you could override FieldRenderingControl, write your own FieldControl. If you don't use this custom field in Whereabouts list you could inherited your fieldcontrol from DateTimeField and override Validate method e.g: