0

I have a calender script in my project. For using it, I have added an image and on its onclick event I call a javascript function displayDatePicker:

<img alt="Calender" src="calender.jpg" onclick="displayDatePicker('txtBox1', this);"/>

I use a masterpage in my project and if the image and the associated textbox control are in contentPlaceHolder, the javasript library's function document.getElementsByName returns null and it seems that it can not detect controls inside a contentPlaceHolder.

I used this code for a page that was not using a masterpage and everything went well.

I appreciate any help from you in advance.

Good luck.

1

1 Answer 1

0

Your asp textbox may render as something like:

<input name="ctl00$FeaturedContent$txtBox1" id="FeaturedContent_txtBox1" type="text"/>

So, in javascript, you should use clientid:

<img alt="Calender" src="calender.jpg" onclick="displayDatePicker('<%= txtBox1.ClientID %>', this);"/>
Sign up to request clarification or add additional context in comments.

Comments

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.