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?