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

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

2 Answers 292 Views
Wizard
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 04 Feb 2016, 01:03 PM

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 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 09 Feb 2016, 11:39 AM
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
0
Ken
Top achievements
Rank 1
answered on 10 Feb 2016, 01:18 PM

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

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

Cheers!

Tags
Wizard
Asked by
Ken
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Ken
Top achievements
Rank 1
Share this question
or