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

RadDatePicker - Style not updated in viewstate

3 Answers 94 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Marbry
Top achievements
Rank 1
Marbry asked on 02 Sep 2011, 08:42 PM

I have a RadDatePicker, and I'm setting the background color on the server side when it contains an invalid value like so:

dtStartDate.DateInput.Style.Add(HtmlTextWriterStyle.BackgroundColor, "red");


Then on the client side, I have this handler attached to the ClientEvents-OnValueChanged event of the child DateInput of the RadDatePicker.

function RemoveInvalidStyle(sender, args)
{
    sender.get_styles().EnabledStyle[0] = sender.get_styles().EnabledStyle[0].replace("background-color:red;", "");
    sender.get_styles().HoveredStyle[0] = sender.get_styles().HoveredStyle[0].replace("background-color:red;", "");
    sender.get_styles().FocusedStyle[0] = sender.get_styles().FocusedStyle[0].replace("background-color:red;", "");
    sender.updateCssClass();
}

This works just fine, they both change the background, but after the client call the background will be reset again on the first postback.  Is this due to that not being persisted in the viewstate?  Or is it being overwritten by the property set on the parent wrapper?

3 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 08 Sep 2011, 07:56 AM
Hello Marbry,

In order to implement the desired functionality, I recommend that you override the .riError style of the RadInput.
Please examine the following help topics for additional information:
Styles
CSS Skin File Selectors

I hope this helps.

Best wishes,
Mira
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Marbry
Top achievements
Rank 1
answered on 08 Sep 2011, 02:31 PM
I was able to get this to work, just resetting it on the server side in addition to the client.  I just added an else and called,

dtStartDate.DateInput.Style.Value = "";

I tried calling the Remove method, but it didn't seem to do anything.  The style was still populated immediately after the call.

dtStartDate.DateInput.Style.Remove(HtmlTextWriterStyle.BackgroundColor);


BTW - the first link you listed above is dead.
0
Mira
Telerik team
answered on 13 Sep 2011, 03:56 PM
Hello Marbry,

I am glad the issue is resolved. Thank you for sharing the solution with the community.
Here is the correct version of the first link.

All the best,
Mira
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Calendar
Asked by
Marbry
Top achievements
Rank 1
Answers by
Mira
Telerik team
Marbry
Top achievements
Rank 1
Share this question
or