Custom Validator and Client-Side function question

I have a custom validator that checks the "ControlToValidate" input text against a javscript function. This is what I have so far:

                <asp:TextBox ID="createFileText" runat="server" />
                <asp:CustomValidator ID="CustomValidator1" runat="server"
                    ErrorMessage="Some error, try again."
                    ClientValidationFunction="CheckFileExists"
                    ControlToValidate="createFileText" />

JS Function:
function CheckFileExists(sender, args)
{ ?? alert(sender.ControlToValidate) ?? }

In the javscript function, I'm trying to get the name of the ControlToValidate from the sender, expecting "createFileText" back. I tried sender.ControlToValidate but got an undefined error. Is this possible?
bemara57Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FlorinAntociCommented:
Hi.

1. Just some info - customvalidators are fire-ing event only if the validating field is not empty (has nothing to do with you question - but just in case)

2. Now, getting to your question, you should use: sender.attributes["controltovalidate"].value   - in order to get the controltovalidate id....

 function vfunction(sender,args)
    {
       alert(sender.attributes["controltovalidate"].value);
       
    }


3. In order to find such "undocumented" things... try to debug the javascript code
   a. IE ->tools->IE options->advanced->disable javascript debug- disable this
   b. You can't set brakepoints...but in the javascript function you need to debug, just add something like alert(vvv);, where vvv is not defined  - and the code will stop there, because vvv is undefined - and VS 2005 IDE will alow you to quick watch any variable within the function, and browse attributes colections or properties.


Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bemara57Author Commented:
Thanks, but it turned out to simply be sender.controltovalidate. Found out using your method :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.