This is a migrated thread and some comments may be shown as answers.
ClientID when created programatically
2 Answers 16 Views
This is a migrated thread and some comments may be shown as answers.
Philip Senechal
Top achievements
Rank 1
Philip Senechal asked on 07 Apr 2011, 08:32 PM
I'm creating a couple of datepickers programatically and I'm adding them to Panel object. I'm trying to add an attribute to the datepickers when they're created to run a JavaScript that opens the calendar when the input box of the date picker is clicked. This works great for datepickers that I've created on the client side and add this attribute server side, but when I create the datepickers server side, I'm not getting the full ClientID.

here is how I'm creating the datepickers and setting the attributes:
Panel edpanelContent = new Panel();
edpanelContent.Attributes.Add("class", "popupcontent");
RadDatePicker eddp = new RadDatePicker();
eddp.ID = "dp_ENDDATE";
eddp.DateInput.Attributes["onclick"] = String.Format("showPopUp('{0}');", eddp.ClientID);
edpanelContent.Controls.Add(eddp);

when I look at the page source, it's referencing the ID being passed to the JavaScript as just "dp_ENDDATE" without all the other pathing that goes along with it. The client id should look like this
ctl00_MainContent_ctl00_RadGrid2_ctl00_ctl02_ctl02_dp_ENDDATE_dateInput_text

Is there a way to set this up so I can assign the JavaScript to the DateInput server side when the control is created? Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Pavel
Telerik team
answered on 08 Apr 2011, 11:02 AM
Hello Philip,

You can simply set the ShowPopupOnFocus property of the DatePicker to "true" as illustrated in this example.

Greetings,
Pavel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Philip Senechal
Top achievements
Rank 1
answered on 08 Apr 2011, 05:49 PM
Thanks for that...I think I was still using pretty old code for my date pickers when that property had to be configured with a JavaScript. I'm going to update all my date pickers now.
Asked by
Philip Senechal
Top achievements
Rank 1
Answers by
Pavel
Telerik team
Philip Senechal
Top achievements
Rank 1
Share this question
or