RadWizard rendered programatically - loosing Title/ValGroup properties on step change

3 posts, 0 answers
  1. Chris
    Chris avatar
    10 posts
    Member since:
    Feb 2014

    Posted 04 Feb Link to this post

    Good morning,

    I have a scenario where I'm creating a RadWizard control dynamically. I'm looping through an object to set up the wizard steps, and then on WizardStepCreated, I'm adding all the controls to the step. The RadWizard's RenderedSteps="All"

    When the page is first rendered, everything works fine. The step Title is populated, the validation groups work fine. The issue I'm having is when I add an ActiveStepChanged method in order to save the data on each step change, I lose my step properties (.Title, .ValidationGroup, etc).

    (See photos attached)

    My code is below. Thank you for your help!

    Chris

    ContentPage:

    <%@ Page Title="Application Rendering Engine" Language="vb" AutoEventWireup="false" MasterPageFile="~/Application.Master" CodeBehind="ApplicationForm.aspx.vb" Inherits="Public_Portal.ApplicationForm" %>
     
    <%@ MasterType VirtualPath="~/Application.Master" %>
     
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     
        <telerik:RadAjaxManagerProxy runat="server" ID="ajaxProxy">
            <AjaxSettings>
            </AjaxSettings>
        </telerik:RadAjaxManagerProxy>
     
     
        <!-- Inside Page Body Content -->
        <div class="container">
            <div class="row">
                <div class="col-sm-12 col-md-12 col-lg-12 col-xs-12">
     
                    <!-- Breadcrumbs -->
                    <ul class="ApplicationFormBreadcrumb">
                        <li>
                            <asp:HyperLink ID="hlBreadcrumb_Home" runat="server" Text="Home" NavigateUrl="~/Default.aspx" />
                        </li>
                        <li>
                            <asp:HyperLink ID="hlBreadcrumb_Dashboard" runat="server" Text="Dashboard" NavigateUrl="~/Dashboard.aspx" />
                        </li>
                        <li class="active">
                            <asp:HyperLink ID="hlBreadcrumb_MyApplication" runat="server" Text="My Application" NavigateUrl="#" />
                        </li>
                    </ul>
     
                </div>
            </div>
            <div class="row">
                <!-- Inside Content Right Side Main -->
                <div class="col-sm-12 col-md-12 col-lg-12 col-xs-12">
                    <div class="tab-content">
     
                        <telerik:RadWizard runat="server" ID="wizMyApplication"
                            Skin="MetroTouch"
                            RenderedSteps="All"
                            DisplayCancelButton="true"
                            DisplayNavigationBar="true"
                            DisplayProgressBar="true"
                            Width="100%"
                            DisplayNavigationButtons="true"
                            NavigationButtonsPosition="Bottom"
                            ProgressBarPosition="left"
                            NavigationBarPosition="left">
                        </telerik:RadWizard>
     
                    </div>
                </div>
            </div>
        </div>
     
     
    </asp:Content>
     

    ContentPage code-behind:

     

    Imports System.IO
    Imports Telerik.Web.UI
    Imports Portal_BusinessObjects
    Public Class ApplicationForm
        Inherits clsPage
     
     
    #Region "Page Events"
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim objApplication As New clsApplication()
     
            If Not Page.IsPostBack Then
     
                If Application_ID > 0 Then
                    objApplication = New clsApplication(Application_ID, Application_Mode)
                Else
                    objApplication = New clsApplication(Application_ID, Application_Mode, Form_Version_ID, Application_EligibleProgram)
                End If
     
                MyApplication = objApplication
     
                '***********************************
                '   BUILD WIZARD STEPS
                '***********************************
                Dim i As Integer = 0
                For Each formStep As clsFormStep In objApplication.Application_Form.Form_Steps
     
                    Dim [wizStep] As New RadWizardStep()
                    Dim strTitle As String = String.Empty
                    Dim strTooltip As String = String.Empty
     
                    If i = 0 Then
                        [wizStep].DisplayCancelButton = False
                    End If
     
                    If clsGlobal.CurrentLang = clsGlobal.AvailableLanguages.en Then
                        strTitle = formStep.E_Name
                        strTooltip = formStep.E_Desc
                    Else
                        strTitle = formStep.F_Name
                        strTooltip = formStep.F_Desc
                    End If
     
                    [wizStep].Title = strTitle
                    [wizStep].ID = "step_" & formStep.Form_Step_ID
                    [wizStep].ValidationGroup = "valGroup_" & wizStep.ID
                    wizMyApplication.WizardSteps.Add([wizStep])
     
                    i = i + 1
                Next
     
            End If
     
        End Sub
     
    #End Region
     
    #Region "Page Control Events"
     
     
     
        '*************************************************************
        '
        '          RENDERING CONTROLS ON WIZARD STEP
        '
        '*************************************************************
        Private Sub wizMyApplication_WizardStepCreated(sender As Object, e As WizardStepCreatedEventArgs) Handles wizMyApplication.WizardStepCreated
            Dim strStepPrefix As String = e.RadWizardStep.ID
            Dim strValidationGroup As String = "valGroup_" & strStepPrefix
            Dim intFormStepID As Integer = CInt(strStepPrefix.Replace("step_", ""))
     
            'Add Step Validation group
            Dim valSummary As New ValidationSummary
            valSummary.ID = "valSum_" & strStepPrefix
     
            Call ConfigureValidationSummary(valSummary, strValidationGroup)
            e.RadWizardStep.Controls.Add(valSummary)
     
            Dim objStep As clsFormStep = MyApplication.Application_Form.Form_Steps.Find(Function(x) x.Form_Step_ID = intFormStepID)
     
            'Loop through all fields in the Form_Step
            For Each field In objStep.Form_Fields
     
                Select Case field.Control_Type_Code
     
                    Case clsFormStepDetail.ControlTypes.Textbox
     
                        Dim txtStandard As ucTextbox = LoadControl("~/Control_Library/Standard_Controls/ucTextbox.ascx")
                        Dim objTexbox As New clsTextbox()
                        With objTexbox
     
                            'Set textbox properties
                            .Textbox_Configuration = objTexbox
                            .Validation_Group = strValidationGroup
     
                        End With
     
                        e.RadWizardStep.Controls.Add(txtStandard)
     
                    Case clsFormStepDetail.ControlTypes.Checkbox
     
                        Dim chkCheckbox As ucCheckbox = LoadControl("~/Control_Library/Standard_Controls/ucCheckbox.ascx")
                        With chkCheckbox
     
                            'Set checkbox properties
                            .Configure_Validation_Required_Field_Ind = field.Validation_Required_Field_Ind
                            .Validation_Group = strValidationGroup
                        End With
     
                        e.RadWizardStep.Controls.Add(chkCheckbox)
     
                    Case clsFormStepDetail.ControlTypes.Dropdown
     
                        Dim ddCodeTable As ucDropdownList = LoadControl("~/Control_Library/Standard_Controls/ucDropdownList.ascx")
                        With ddCodeTable
     
                'Set dropdown properties
                            .Configure_Validation_Required_Field_Ind = field.Validation_Required_Field_Ind
                            .Validation_Group = strValidationGroup
                        End With
     
                        e.RadWizardStep.Controls.Add(ddCodeTable)
     
     
                End Select
     
     
            Next
     
     
     
        End Sub
     
     
        '*************************************************************
        '
        '           FINISH BUTTON - SAVE CODE GOES HERE
        '
        '*************************************************************
        Private Sub wizMyApplication_FinishButtonClick(sender As Object, e As WizardEventArgs) Handles wizMyApplication.FinishButtonClick
     
        Call SaveApplicationForm()
     
            Response.Redirect("~/Dashboard.aspx?msg=applicationSubmitted")
     
        End Sub
     
     
     
        Private Sub wizMyApplication_ActiveStepChanged(sender As Object, e As EventArgs) Handles wizMyApplication.ActiveStepChanged
     
        Call SaveApplicationForm()
     
        End Sub
     
     
    #End Region
     
     
    #Region "Functions and Sub-routines"
     
        Private Sub ConfigureValidationSummary(ByVal valSum As ValidationSummary, ByVal strValGroup As String)
     
            With valSum
                .DisplayMode = ValidationSummaryDisplayMode.BulletList
                .ShowMessageBox = False
                .ValidationGroup = strValGroup
                .ShowSummary = True
                .CssClass = "alert alert-danger"
     
            End With
     
        End Sub
     
         
        Private Sub SaveApplicationForm()
             
        'Save form values to database here
     
        End Sub
     
    #End Region
     
     
     
    End Class

     

     

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    290 posts

    Posted 09 Feb Link to this post

    Hi Chris,

    The observed behavior is due to the fact that when added dynamically, RadWizardSteps persist only their ID property after postback. To avoid the observed issue, I would recommend you to set the title and the validation group of the step in the OnWizardStepCreated event handler, where you also generate and add the controls for the specific step. For reference, you could consult this RadWizard demo.

    I hope that the above helps you.

    Regards,
    Veselin Tsvetanov
    Telerik
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chris
    Chris avatar
    10 posts
    Member since:
    Feb 2014

    Posted 10 Feb in reply to Veselin Tsvetanov Link to this post

    Wow, I'm not sure why I didn't think of that!

     Your solution worked perfectly, thank you so much for your assistance.

    Cheers!

Back to Top