Themelia Pro A powerful new development platform built on ASP.NET.
 
Working with Views
 
 

In Creating Sequences, the overall structure of a sequence is discussed. Here we will look more closely at the content of a view and some of the things a view can do.

Here is our example view:

<%@ Control AutoEventWireup="false" Language="C#" Inherits="Sequence.ResetPassword.Input" CodeFile="Input.ascx.cs" %>

Password Reset




Here is the code behind for this view: code behind we have something like that looks like this:

using System;
//+
namespace Sequence.Account
{
    public partial class Root : Themelia.Web.Controls.SequenceUserControl
    {
        //- #OnInit -//
        protected override void OnInit(EventArgs e)
        {
            btnSubmit.Click += new EventHandler(OnSubmit);
            //+
            base.OnInit(e);
        }
 
        //- $OnSubmit -//
        private void OnSubmit(object sender, EventArgs e)
        {
            litError.Text = String.Empty;
            //+
            Boolean success = LoginClient.RunCustomPasswordResetLogic(txtEmail.Text);
            if (success)
            {
                this.MoveToNextView();
            }
        }
    }
}

Just about everything about this is classic ASP.NET. However, notice that when the password reset is successful, the control makes a call to MoveToNextView. This is one of four different navigation methods to which both the sequence page and the sequence user control have access. Here are the navigation methods:

  • MoveToFirstView
  • MoveToLastView
  • MoveToPreviousView
  • MoveToNextView
  • MoveToView (which takes the name of the view)

The function of each of them should be obvious. In this case, when we know the password reset has been successful, we can simply move to the next view. Therefore, the order of the sequence views are important to the success of sequence.

View Initialization

One extremely important note about sequences is that when you switch to a new view using one of the above methods, the OnViewInit method is called on the newly loaded sequence user control. This is very important for wizard scenarios. For example, say you are on view A and on this view you are asking for the user's first name, last name, and e-mail address. If you needed any information on the second view, how does it get there?

The recommended solution for this is saving the information is HttpData and loading the information in OnViewInit on the next sequence user control. For example, do this on view A:

//- $OnSubmit -//
private void OnSubmit(Object sender, EventArgs e)
{
    Themelia.Web.HttpData.SetScopedItem<String>("Source", "Email", txtEmail.Text);
    //+
    this.MoveToNextView();
}

Then on the next view, do this:

//- @OnViewInit - //
public override void OnViewInit()
{
    litEmailAddress.Text = Themelia.Web.HttpData.GetScopedItem<String>("Source", "Email");
}

Of course, the HttpData class also allows you to more than just strings. If you want to use a business object, you could store that in HttpData as well.