Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am having a datetime control in sharepoint custom webpart

<SharePoint:DateTimeControl 
        runat="server" 
        ID="txtUKdtofAdm" 
        LocaleId="2057" 
        DateOnly="True"
        OnValueChangeClientScript="validateControlsUK();" 
        AutoPostBack="true" 
        OnDateChanged="txtUKdtofAdm_OnDateChanged">
</SharePoint:DateTimeControl>

I want to call a js as well as server side function on date changed. I have done as above but, client side function does not execute. Can anyone help me in order to get this working wherein if a date is changed than both js on client side and onchange server side event should work.

In my case only server side is getting fired.

Thank you in advance.

share|improve this question
add comment

2 Answers

I think you should remove the ; from the end of validateControlsUK(); and it will work. So your call should be like this: OnValueChangeClientScript="validateControlsUK()". Also, be aware, that Javascript is case sensitive. I don't know what is the function name in your javascript, but there is a difference between ValidateControlsUK and validateControlsUK. :) If that didn't work, here are some advice, how to troubleshoot: 1. You could try this line, to see if it's even a valid event you are trying to catch: OnValueChangeClientScript="javascript:alert('Date changed');" 2. If step 1 succeeds, you should put in your function, validateControlsUK, at the very beginning of it, a similar alert as above. This way you will know at least that your client side validation is triggered, but it's ill-performing for other reasons.

I hope this helped.

share|improve this answer
    
Sorry that did not work. –  Ishan Jul 7 '12 at 6:27
add comment
up vote 0 down vote accepted

Ok i got the solution to this.

I removed AutoPostBack="true" and in javascript i used __doPostBack('<%= txtUKdtofAdm.Controls[0].ClientID %>', ''); which forces a postback which inturn fires OnDateChanged="txtUKdtofAdm_OnDateChanged"

Thank You

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.