ASP.NET 4.0 has introduced the property 'ClientIDMode', which allows one to specify how the html element's ids are rendered in the output html.
My project is currently set to 'Static' (the shortest / contains no hierarchy id's)
When using any validator (RequiredFieldValidator
, RegularExpressionValidator
...), unless the control it's validating explicitly has it's property ClientIDMode:AutoID I get the error:
Input parameter开发者_运维技巧 'controlId' cannot be an empty string.
Is this the expected behaviour?
Edit: Being abit dumb with the error message, it wanted me to put an id on the Validator, which I obviously dont do (unless I need to reference it).
It still seems odd that it should fail because of this reason.
I ran into this in a slightly different way: if my user control had ClientIDMode="Static"
, I received the error on the validators that existed within the control (they did not all have ID's).
One workaround is to switch ClientIDModes on the offending user control. Hope this helps!
精彩评论