My custom ASP.Net RequiredFieldValidator renders markup like this…
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 = "";
However, there appears to be no way to set the evaluationfunction property. I need to do this to call some custom script.
Ive tried the following methods.
- Adding a new attribute when the control is rendered and when the attributes are rendered
- Calling RemoveAttribute followed by Attributes.Add
- Attempting to reset it via javascript.
Nothing seems to work.
If I can get a solution that works in the c# code to set the attribute before render that would be the best for what Im doing.
Solved by doing the following….
ASP.Net validators actually define a span on the page, which is a DOM object in Javascript. They then add properties to that object. So you get something like this in the code generated by ASP.Net.
You can then inject some javascript into your page that does something like this using Page.ClientScript.Register(….) in your code behind…
The validation function has now been changed to use your custom function.