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

How to maintain dynamic Radwizards or how can i ajaxify dynamic radwizard

0 Answers 39 Views
Wizard
This is a migrated thread and some comments may be shown as answers.
Saifulla
Top achievements
Rank 1
Saifulla asked on 12 Feb 2019, 11:52 AM

I have created radwizardsteps dynamically, which is in a user control, onstep change i am creating another rad wizard with 4 steps dynamically and every step contains a dynamic table. Now the problem is if i make a another ajax request the controls in the 2nd wizard getting destroyed, how can i maintain this controls can someone help out to resolve this.
Thanks.

Usercontrol.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WizardUCDemo.ascx.cs" Inherits="WebUIFrameWork.UITemplate.WizardUCDemo" %>
<telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
<script type="text/javascript">
    function OnWizardstepChange() {
        var radManager = null;
        var stepIndex = $find("<%= wizardControl.ClientID %>").get_activeIndex();
        radManager = $find('<%=RadAjaxManager.GetCurrent(this.Page).ClientID%>');
        radManager.ajaxRequest("StepChange&"+stepIndex);
    }
</script>
</telerik:RadCodeBlock>
<telerik:RadWizard runat="server" RenderMode="Lightweight" ID="wizardControl" OnClientButtonClicked="OnWizardstepChange"
    DisplayProgressBar="false" ProgressBarPosition="Right" NavigationBarPosition="Right"
    NavigationButtonsPosition="Bottom" DisplayNavigationButtons="false">
</telerik:RadWizard>

 

Usercontrol.ascx.cs:

public void GenerateSteps()
{
 for (int i = 1; i < 5; i++)
 {
    Step = new RadWizardStep();
    Step.ID = "Step_" + i.ToString();
    Step.ClientIDMode = ClientIDMode.Static;
 
    Table = new Table();
    Table.ID = "Table" + i.ToString();
    Table.ClientIDMode = ClientIDMode.Static;
    newStep.Controls.Add(newTable);
    UIControlsWizard.WizardSteps.Add(newStep);
 }

aspx:

<telerik:RadCodeBlock runat="server">
<script type="text/javascript">
      function testMethod()
      {
          $find("<%= RadAjaxManager1.ClientID%>").ajaxRequest("demo")
      }
</script>
</telerik:RadCodeBlock>
 
<telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
       <AjaxSettings>
           <telerik:AjaxSetting AjaxControlID="wizardControl">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="wizardControl" />
               </UpdatedControls>
           </telerik:AjaxSetting>
       </AjaxSettings>
</telerik:RadAjaxManager>
 <table>
        <tr>
            <td>
                <uc1:WizardUCDemo runat="server" ID="WizardUCDemo1" />
            </td>
            <td>
                <telerik:RadWizard runat="server" RenderMode="Lightweight" ID="RadWizard1" DisplayProgressBar="false"
                    ProgressBarPosition="Right" NavigationBarPosition="Right" NavigationButtonsPosition="Bottom"
                    DisplayNavigationButtons="false">
                </telerik:RadWizard>
            </td>
        </tr>
    </table>

 

aspx.cs:

Table newTable;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            WizardUCDemo.GenerateSteps();
        }
    }
public void reProduceWizardSteps()
{
   RadWizardStep newStep;
   for (int i = 1; i < 5; i++)
   {
       newStep = new RadWizardStep();
       newStep.ID = "newStep_" + i.ToString();
       newStep.ClientIDMode = ClientIDMode.Static;
 
       newTable = new Table();
       newTable.ID = "newTable" + i.ToString();
       newTable.ClientIDMode = ClientIDMode.Static;
       TableRow tRow = new TableRow();
       TableCell tCell = new TableCell();
 
       RadTextBox rtxtBoxNew = new RadTextBox();
       rtxtBoxNew.ID = "newTextBox_" + i.ToString();
       rtxtBoxNew.ClientIDMode = ClientIDMode.Static;
       rtxtBoxNew.ClientEvents.OnKeyPress = "testMethod";
       tCell.Controls.Add(rtxtBoxNew);
       tRow.Cells.Add(tCell);
       newTable.Controls.Add(tRow);
       newStep.Controls.Add(newTable);
       UIControlsWizard.WizardSteps.Add(newStep);
    }
}
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
   string commandText = e.Argument.ToString().Trim();
   var commandData = commandText.Split('&');
   commandText = commandData[0];
   switch (commandText)
   {
      case "StepChange":
          if (Convert.ToInt32(commandData[1])==1)
          {
              reProduceWizardSteps();
          }
              break;
   }
}

 

No answers yet. Maybe you can help?

Tags
Wizard
Asked by
Saifulla
Top achievements
Rank 1
Share this question
or