change background color raddatepicker

6 posts, 0 answers
  1. Duy
    Duy avatar
    24 posts
    Member since:
    Jun 2013

    Posted 23 Jan 2014 Link to this post

    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;
            }
  2. Duy
    Duy avatar
    24 posts
    Member since:
    Jun 2013

    Posted 24 Jan 2014 Link to this post

    please help. thank you
  3. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2286 posts

    Posted 28 Jan 2014 Link to this post

    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.
  4. Duy
    Duy avatar
    24 posts
    Member since:
    Jun 2013

    Posted 28 Jan 2014 in reply to Viktor Tachev Link to this post

    It does but I have 2 radiate picker and it always the first one bc the text box element name is the same
  5. Duy
    Duy avatar
    24 posts
    Member since:
    Jun 2013

    Posted 28 Jan 2014 in reply to Viktor Tachev Link to this post

    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
  6. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2286 posts

    Posted 30 Jan 2014 Link to this post

    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.
Back to Top