1

I'm trying to use the jquery datepicker - http://jqueryui.com/demos/datepicker/ in a custom control (.ascx).

To enable the datepicker, I need to add the following script at the top for an input:

$("#dateinput").datepicker({});

The problem is, that the id of the element changes when the custom control is on a page. When the custom control is given an id of "c1" for example, the id field becomes "c1_dateinput".

How do I get around this? I need multiple custom controls with datepickers on the page.

3 Answers 3

4

If you need multiple controls to have datepickers I would use a class. Assign a CSS class to anything that needs a datepicker and your javascript becomes this:

$(".datepicker").datepicker(); 
Sign up to request clarification or add additional context in comments.

Comments

2

use a class say date.

Then simply do -

$("input.date").datepicker();

This will create a datepicker for each input that has a class of date.

Comments

0

You will need to use the Control.ClientID property to get around this. This way you can get the rendered client id no matter what it is.

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.