2

I found a bug on my site and I can't seem to find a solution. I am dynamically generating controls, two of which are a RadDatePicker and a RadTimePicker. When different events occur on the page, I am changing the visibility of the controls between true and false after generating them (essentially based on whether the page is in 'edit' mode or view mode). However, after the first instance where the controls are visible, the controls lose their styles. Refer to the screenshot below:

RadDatePicker and RadTimePicker style loss example

If anyone has any suggestions, or advice, that'd be great. Thanks

Update: Here is the code as requested

This hides and shows controls(just change true/false)

for (int i = 0; i < customProperties.Rows.Count; i++)
{
    customProperties.FindControl("CustomControl" + (i + 1).ToString()).Visible = false;
    customProperties.FindControl("lblCustomControl" + (i + 1).ToString()).Visible = true;
    Type aType = customProperties.FindControl("CustomControl" + (i + 1).ToString()).GetType();
    if (aType.Name == "RadBinaryImage")
    customProperties.FindControl("CustomControl" + (i + 1).ToString() + "_btn").Visible = false;
}

So basically it searches the htmltable (customProperties) for controls and changes the visibility

This is where the control is generated:

case DynamicFieldTypeEnum.Date:
    RadDatePicker dp = new RadDatePicker();
    dp = currentValues as RadDatePicker;
    if (dp.SelectedDate == null)
        customProperty.Text = "Not Specified";
    else
        customProperty.Text = dp.SelectedDate.Value.ToString(dp.DateInput.DateFormat);
    dp.ID = "CustomControl" + (position + 1).ToString();

    newControls[0] = customProperty;
    newControls[1] = dp;
    break;
case DynamicFieldTypeEnum.Time:
    RadTimePicker tp = new RadTimePicker();
    tp = currentValues as RadTimePicker;
    if (tp.SelectedDate == null)
        customProperty.Text = "Not Specified";
    else
        customProperty.Text = tp.SelectedDate.Value.ToString(tp.DateInput.DateFormat);
    tp.ID = "CustomControl" + (position + 1).ToString();

    newControls[0] = customProperty;
    newControls[1] = tp;
    break;

This is within a method that is given an object definition and then returns a control array. The first value in the control array is a label for "view" mode and the second control is a control for "edit" mode.

This array is then passed to a different method which places the controls within a table cell which is placed in a table row and then placed in the table "customProperties"

Eric
  • 1,356
  • 2
  • 14
  • 24
  • Firstly, are there any post-backs occurring? Second, are these controls located inside something such as an update panel? – KreepN Jun 19 '12 at 15:40
  • Yes a postback occurs when I am "cancelling" edit mode, ie. not saving the information. Which is when this bug occurs. The controls are placed within a regular html table, nothing else. – Eric Jun 19 '12 at 16:08
  • One more silly question, but do you have a RadStyleSheetManager control anywhere on your page? – KreepN Jun 19 '12 at 16:53
  • Nope I don't. Should I? haha. – Eric Jun 19 '12 at 16:57
  • Quite possibly, http://www.telerik.com/help/aspnet-ajax/stylesheetmanager.html (Telerik's Page on the control for reference) . Use the little popup box on the control to add the required web.config entry. Try that and let me know what happens, if it works I'll drop an answer below, but if not I'll keep digging for ya. – KreepN Jun 19 '12 at 16:58
  • Unforuntately it didn't work :P thanks for the suggestion though (: – Eric Jun 19 '12 at 20:06
  • If you don't mind posting code, or submitting the small part of the solution to me, I'd be more than glad to take a look for you. Just make sure you take out personal and confidential info :). – KreepN Jun 19 '12 at 23:27
  • Updated my question with the code (: – Eric Jun 20 '12 at 16:58

1 Answers1

0

I have already experienced this kind of problem.

As a suggestion of Telerik Support, I added this code in the pages I found your problems.

    <telerik:RadStyleSheetManager ID="RadCssManager" runat="server">
        <StyleSheets>
            <telerik:StyleSheetReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Skins.RadDatePicker.css" />
            <telerik:StyleSheetReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Skins.MetroTouch.RadDatePicker.MetroTouch.css" />
        </StyleSheets>
    </telerik:RadStyleSheetManager>

Ps: in my case I'm using the "MetroTouch" Skin.

Jacobi
  • 1,508
  • 15
  • 29