+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / ASP.NET Wizard Control - Form Fields becoming invisible after editing in Sitefinity

ASP.NET Wizard Control - Form Fields becoming invisible after editing in Sitefinity

11 posts, 0 answered
  1. Scott McNeany
    Scott McNeany avatar
    44 posts
    Registered:
    09 Mar 2010
    07 Oct 2010
    Link to this post
    Hello, I have an issue dealing with a Wizard control in Sitefinity. I can reproduce it each time by doing the following:

    1. Add a wizard control to a user control with several labels and textboxes. 
    2. Add Labels, TextBoxes, and Wizard as properties in code-behind to make them accessible in Sitefinity Admin.
    3. Add the user control to the toolbox in web.config.
    4. Open Sitefinity Admin and add the user control to the page.
         Note: At this stage, the labels and textboxes display appropriately.
    5. Edit the control, and save without actually making any changes.
         Note: At this stage, the labels and textboxes "Visible" property have all been set to 'False' and the labels and textboxes no longer appear on the screen.

    Additional Note: This only affects properties that are configurable through Sitefinity. For example, if I do not create a property in the code-behind for one of the TextBoxes, it will be unaffected by the the Save and will display correctly.

    Below is the markup, and a few of the properties in the code-behind.

    -------------------------
    Markup
    --------------------------

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="TestControl.ascx.cs"
        Inherits="TestControl" %>
    <table style="width: 525px">
        <tr>
            <td colspan="2">
                <img:ValidationSummary runat="server" ID="validationSummary" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Wizard ID="Wizard1" runat="server" OnFinishButtonClick="Wizard1_FinishButtonClick">
                    <WizardSteps>
                        <asp:WizardStep ID="wzStep1" runat="server" Title="Account">
                            <table>
                                <tr>
                                    <td>
                                        <asp:Label runat="server" ID="lblPrimaryEmail" Text="Primary Email"></asp:Label>&nbsp;
                                    </td>
                                    <td>
                                        <asp:TextBox runat="server" ID="txtPrimaryEmail"></asp:TextBox>
                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator_txtPrimaryEmail"
                                            ControlToValidate="txtPrimaryEmail" Display="None" ErrorMessage="Primary Email Required."></asp:RequiredFieldValidator>
                                        <img:RegularExpressionValidator runat="server" ID="RegularExpressionValidator_txtPrimaryEmail"
                                            ControlToValidate="txtPrimaryEmail" Display="None"></img:RegularExpressionValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Label runat="server" ID="lblConfirmPrimaryEmail" Text="Confirm Primary Email"></asp:Label>&nbsp;
                                    </td>
                                    <td>
                                        <asp:TextBox runat="server" ID="txtConfirmPrimaryEmail"></asp:TextBox>
                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator_ConfirmPrimaryEmail"
                                            ControlToValidate="txtConfirmPrimaryEmail" Display="None" ErrorMessage="Confirm Primary Email Required."></asp:RequiredFieldValidator>
                                        <asp:CompareValidator runat="server" ID="CompareValidator_PrimaryEmails" ControlToValidate="txtConfirmPrimaryEmail"
                                            ControlToCompare="txtPrimaryEmail" Display="None" ErrorMessage="Primary Email must match Confirm Primary Email."></asp:CompareValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                        <telerik:RadCaptcha runat="server" ID="captchaControl" Visible="false" Display="None">
                                        </telerik:RadCaptcha>
                                    </td>
                                </tr>
                            </table>
                        </asp:WizardStep>
                        <asp:WizardStep ID="wzStep2" runat="server" Title="Information">
                        </asp:WizardStep>
                        <asp:WizardStep ID="wzStep3" runat="server" Title="Complete">
                            <table>
                                <tr>
                                    <td colspan="2">
                                        <asp:Label runat="server" ID="lblSuccessMessage"></asp:Label>
                                    </td>
                                </tr>
                            </table>
                        </asp:WizardStep>
                    </WizardSteps>
                </asp:Wizard>
            </td>
        </tr>
    </table>


    -------------------------
    C# Code-Behind
    --------------------------

    [Browsable(true),
         Category("Labels"),
         Description("Allows the administrator to customize any of the properties of this label.")]
        public Label Label_PrimaryEmailAddress
        {
            get
            {
                return this.lblPrimaryEmail;
            }
        }


     [Browsable(true),
        Category("Form Fields"),
        Description("Allows the administrator to customize the properties of this textbox.")]
        public TextBox TextBox_PrimaryEmailAddress
        {
            get
            {
                return this.txtPrimaryEmail;
            }
        }
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    08 Oct 2010
    Link to this post
    Hello Scott McNeany,

    Thank you for using our services.

    The problem is that the label and text box exist in the wizard steps and are not initialized when the control is being edited. What has to be done is to create properties such as label and text box and pass their values to the ones existing in the control.

    Regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Scott McNeany
    Scott McNeany avatar
    44 posts
    Registered:
    09 Mar 2010
    13 Oct 2010
    Link to this post
    Radoslav,

    I don't understand what you mean by "pass their values to the ones existing in the control". Could you elaborate on this?

    I have properties already in the code-behind, so what is the next step?

    Thank you,

    Scott
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    13 Oct 2010
    Link to this post
    Hi Scott,

    Could you explicitly set Visible property of

    • txtPrimaryEmail
    • txtConfirmPrimaryEmail

     to True inside OnPreRender of your control.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Scott McNeany
    Scott McNeany avatar
    44 posts
    Registered:
    09 Mar 2010
    15 Oct 2010
    Link to this post
    This seems really tedious. I have about 60 controls total (Labels, Buttons, TextBoxes, etc.) inside the RadMultiPage (I converted it from a Wizard to a RadMultiPage, but the behavior is the same).

    Is there no other way around this besides to set EVERY control's visible property to True inside OnPreRender?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Oct 2010
    Link to this post
    Hello Scott,

    I am not able to replicate the issue when I am using RadMultiPage. I added a TextBox inside the RadPageView and the issue does not appear in this case

    <telerik:RadTabStrip ID="RadTabStrip1" SelectedIndex="0" runat="server" MultiPageID="RadMultiPage1" skin="Outlook"  CssClass="NoBg">
     <Tabs>
       <telerik:RadTab runat="server" Selected="True" Text="Root RadTab1" PageViewID="PageView3">
       </telerik:RadTab>
       <telerik:RadTab runat="server" Text="Root RadTab2" PageViewID="PageView2">
       </telerik:RadTab>
       <telerik:RadTab runat="server" Text="Root RadTab3" PageViewID="PageView1">
       </telerik:RadTab>
     </Tabs>
    </telerik:RadTabStrip>
    <telerik:RadMultiPage id="RadMultiPage1" runat="server" SelectedIndex="0" Width="400">
      <telerik:RadPageView id="Pageview1" runat="server">
          <asp:TextBox runat="server" ID="MultiPageTextBox"></asp:TextBox>Textbox
      </telerik:RadPageView>
      <telerik:RadPageView id="Pageview2" runat="server">
       test content 2
      </telerik:RadPageView>
      <telerik:RadPageView id="Pageview3" runat="server">
         test content 3
      </telerik:RadPageView>
    </telerik:RadMultiPage>

    code behind

    public TextBox TB
    {
        get
        {
            return this.MultiPageTextBox;
        }
    }

    This issue occurs only when you use the ASP.NET Wizard control.


    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Scott McNeany
    Scott McNeany avatar
    44 posts
    Registered:
    09 Mar 2010
    18 Oct 2010
    Link to this post
    Ivan,

    I have only experienced this with server controls on Page 2 or later. Try adding another TextBox to Page 2, add a property in the code-behind, edit the control in Sitefinity, then re-open the page in the web browser. The controls on Page 2 should be invisible.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Oct 2010
    Link to this post
    Hello Scott,

    There is no issue if you put three TextBox controls and set the Text property through the ControlDesigner.

    Below is a sample code.

    <telerik:RadTabStrip ID="RadTabStrip1" SelectedIndex="0" runat="server" MultiPageID="RadMultiPage1" skin="Outlook"  CssClass="NoBg">
     <Tabs>
       <telerik:RadTab runat="server" Selected="True" Text="Root RadTab1" PageViewID="PageView1">
       </telerik:RadTab>
       <telerik:RadTab runat="server" Text="Root RadTab2" PageViewID="PageView2">
       </telerik:RadTab>
       <telerik:RadTab runat="server" Text="Root RadTab3" PageViewID="PageView3">
       </telerik:RadTab>
     </Tabs>
    </telerik:RadTabStrip>
    <telerik:RadMultiPage id="RadMultiPage1" runat="server" SelectedIndex="0" Width="400">
      <telerik:RadPageView id="Pageview1" runat="server">
          <asp:TextBox runat="server" ID="MultiPageTextBox"></asp:TextBox>Textbox
      </telerik:RadPageView>
      <telerik:RadPageView id="Pageview2" runat="server">
       <asp:TextBox runat="server" ID="MultiPageTextBox2"></asp:TextBox>Textbox2
      </telerik:RadPageView>
      <telerik:RadPageView id="Pageview3" runat="server">
         <asp:TextBox runat="server" ID="MultiPageTextBox3"></asp:TextBox>Textbox3
      </telerik:RadPageView>
    </telerik:RadMultiPage>

    code behind

    public TextBox TB1
    {
        get
        {
            return this.MultiPageTextBox;
        }
    }
     
    public TextBox TB2
    {
        get
        {
            return this.MultiPageTextBox2;
        }
    }
     
    public TextBox TB3
    {
        get
        {
            return this.MultiPageTextBox3;
        }
    }


    I am also attaching a short video.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Scott McNeany
    Scott McNeany avatar
    44 posts
    Registered:
    09 Mar 2010
    18 Oct 2010
    Link to this post
    It seems to be related to a specific property on the RadMultiPage called 'RenderSelectedPageOnly'.

    When I set this property to 'true', I get the behavior described in the post. 

    When I set the property to 'false', all fields render correctly. However, the validation controls that are meant for Pages 2 and 3 will fire on Page 1. I was able to disable all validation controls and proceed as normal, but obviously I want to hook these back up before checking this in.

    Let me know what you find.

    Thank you,

    Scott
  10. Scott McNeany
    Scott McNeany avatar
    44 posts
    Registered:
    09 Mar 2010
    19 Oct 2010
    Link to this post
    Hey guys,

    I was able to get around this issue by running the following generic code, which loops through all child controls and sets the visible property. It is recursive, so I don't need to worry about setting it for each Label, Button, etc.


       protected void Page_PreRender(object sender, EventArgs e)
        {
            foreach (object c in this.Controls)
            {
                if ((c as WebControl) != null)
                {
                    WebControl control = c as WebControl;
                    ShowChildren(control); //Recursive function
                }
            }
        }

        private void ShowChildren(WebControl control)
        {
            if (control.HasControls())
            {
                foreach (object c in control.Controls)
                {
                    if ((c as WebControl) != null)
                    {
                        WebControl childControl = c as WebControl;
                        ShowChildren(childControl);
                        childControl.Visible = true;
                    }
                }
            }
        }
  11. Scott McNeany
    Scott McNeany avatar
    44 posts
    Registered:
    09 Mar 2010
    19 Oct 2010
    Link to this post
    Correction. I had to add a small tidbit to the ShowChildren() method so that validators don't get set to visible on pre-render. If casting them to 'BaseValidator' yields an object, then I simply return.

    private void ShowChildren(WebControl control)
        {
            if (control.HasControls())
            {
                foreach (object c in control.Controls)
                {
                    //We don't want to enable validators on pre-render.
                    if ((c as BaseValidator) != null)
                    {
                        return;
                    }

                    if ((c as WebControl) != null)
                    {
                        WebControl childControl = c as WebControl;
                        ShowChildren(childControl);
                        childControl.Visible = true;
                    }
                }
            }
        }
Register for webinar
11 posts, 0 answered