1
我定制的ASP.Net的RequiredFieldValidator呈现类似这样的标记......ASP.Net的RequiredFieldValidator定制EvaluationFunction财产
var af1_ctl00 = document.all ? document.all["af1_ctl00"] : document.getElementById("af1_ctl00");
af1_ctl00.controltovalidate = "af1_af1_txt";
af1_ctl00.display = "None";
af1_ctl00.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
af1_ctl00.initialvalue = "";
然而,似乎没有办法设置evaluationfunction财产。我需要这样做来调用一些自定义脚本。
我试过以下方法。
- 添加新的属性,当控制被渲染,并且当属性被呈现
- 的removeAttribute调用随后Attributes.Add
- 试图通过JavaScript重置。
似乎没有任何工作。
如果我可以得到一个解决方案,在c#代码中设置属性之前渲染,这将是我在做什么最好的。
请参阅我的答案http://stackoverflow.com/questions/792858/how-do-i-hook-up-javascript-to-my-customvalidator-control-in-net/37150996#37150996 – 2016-05-11 18:04:26