1

I want to access a boolean property of my User Control through Java Script. For this I do:

..=document.getElementById('<%= dtPickerBirth.ClientID%>').IsValidDate;

As you might guess IsValidDate is a boolean value and I want to access it. Is there anything wrong with this code? I use this for validation purposes but it does not work.

1
  • 1
    That property will only be available on the server side, so if you really need that you'll have to use ajax. Looks like you should implement a separate client-side validation layer. Commented Apr 16, 2012 at 13:54

1 Answer 1

1

What about ..= '<%= dtPickerBirth.IsValidDate %>'; ?

Sign up to request clarification or add additional context in comments.

5 Comments

Yeah, body, that really does the job except it seems as boolean values in Java Script and C# are different. Why? Because I assign the IsValidDate property to args.IsValid. And on validation I get browser error."False is undefined". I see this when debugging. IsValidDate returns False but there's problem in setting this value to args.IsValid.
I think you have to parse the value returned by the IsValidDate by hand in the javascript side, instead of assigning it directly to args.IsValid
How can I check <%= dtPickerBirth.IsValidDate%> value and act accordingly?
var isValidDate = '<%= dtPickerBirth.IsValidDate %>'; if(isValidDate == 'True') { args.IsValid = true; } else { args.IsValid = false; }
Please check if you are getting False in the variable. Also, this code can be optimized...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.