This is a migrated thread and some comments may be shown as answers.

change background color raddatepicker

5 Answers 188 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Duy
Top achievements
Rank 1
Duy asked on 23 Jan 2014, 02:52 PM
Code below allow me to loops through all rad controls on the page. it is working except when I have 2 raddatepicker. it doesn't know which dateinput textbox to hight light even though it gets the right id of the current selected one. please help. thanks


function Validation() {
            var allRadComboBoxes = [];
            var allRadControls = $telerik.radControls;
            for (var i = 0; i < allRadControls.length; i++)
            {
                var element = allRadControls[i];
                if (Telerik.Web.UI.RadComboBox && element instanceof Telerik.Web.UI.RadComboBox) {
                    Array.add(allRadComboBoxes, element);
                }
            }
             
            for (var i = 0; i < allRadComboBoxes.length; i++)
            {
                var CurrentControlID = allRadComboBoxes[i].get_id();
                var TextControlID = CurrentControlID.replace("ddl", "txt");
                var TextControl = $find(TextControlID);
                switch (allRadComboBoxes[i].get_text().toLowerCase())
                {
                    case "figure":
                        if (allRadComboBoxes[i].get_text().toLowerCase() == "actual date")
                        {
                            TextControlID = CurrentControlID.replace("ddl", "dp");
                            TextControl = $find(TextControlID);
                            alert(TextControlID);
                        }
                        if (document.getElementById(TextControlID).value == "")
                        {
                            if (TextControlID.indexOf("txt") >= 0)
                            {
                                TextControl.get_styles().EnabledStyle[0] += "background-color: red;";
                                TextControl.updateCssClass();
                                return false;
                            }
                            else
                            {
                                alert($find("<%=dp_DateArtworkAcquired%>"));
                                TextControl.get_dateInput()._textBoxElement.style.backgroundColor = "red";
                                return false;
                            }
                        }
                }
            }
            return false;
        }

5 Answers, 1 is accepted

Sort by
0
Duy
Top achievements
Rank 1
answered on 24 Jan 2014, 02:27 PM
please help. thank you
0
Viktor Tachev
Telerik team
answered on 28 Jan 2014, 09:42 AM
Hi,

The approach you are using should set the background color for a DateInput of a RadDatePicker control as expected. Please ensure that there are no JavaScript errors on the page that would prevent the style from being applied.

Regards,
Viktor Tachev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Duy
Top achievements
Rank 1
answered on 28 Jan 2014, 01:57 PM
It does but I have 2 radiate picker and it always the first one bc the text box element name is the same
0
Duy
Top achievements
Rank 1
answered on 28 Jan 2014, 05:32 PM
i noticed that because i set clientidmode="static" server postback doesn't work correctly either. like ajax postback stop working and it reloads the whole page, also if you have multple calendar controls on the same page, it will not work properly for the second calendar. maybe this is the reason why the javscript doesn't work correctly
0
Viktor Tachev
Telerik team
answered on 30 Jan 2014, 01:02 PM
Hello,

Setting ClientIDMode to Static is not recommended when using Telerik controls and especially when Ajax requests are performed. This mode is intended to be used with static controls on the page.

Our controls use complex hierarchies of child controls and templates and setting Static id mode could break their functionality. You should set ClientIDMode to AutoID with Telerik controls.

Regards,
Viktor Tachev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
General Discussions
Asked by
Duy
Top achievements
Rank 1
Answers by
Duy
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or