add custom attribute to RadDatePicker

144 Views Asked by At

I'm trying to add a custom attribute on a RadDatePicker but it adds the attribute to the wrapper instead of the inputfield. is there a way to add an attribute to the input field of a RadDatePicker

I found that if I opened the controls and selected the first value in my watch, I'd get the input field + it had an attributes attribute. but when trying to add an attribute to the first Control, it gives a red squigly line saying that rdp.Controls[0].Attributes doesn't exist.

my code:

RadDatePicker rdp = (RadDatePicker)control_object[control_id];
rdp.Attributes.Add("controlID", control_id);

rdp.Controls[0].Attributes.Add("controlID", control_id);
1

There are 1 best solutions below

2
On BEST ANSWER

I figured it out,

I had to define the rdp.Controls[0] as a radDateInput.

//1 liner
((RadDateInput)rdp.Controls[0]).Attributes.Add("controlID", control_id);

//2 lines
RadDateInput rdi = (RadDateInput)rdp.Controls[0];
rdi.Attributes.Add("controlID", control_id);