The SurveyManager class is the main workhorse of the framework. You instantiate it with an XmlNode that contains an arbitrary element in your survey definition. In our sample, this is the page element.

  <page id="1">

The element passed to the SurveyManager instance should contain one or more control elements.
SurveyManager iterates through the control elements and tries to instantiate a SurveyControl of a type specified by the type attribute. The SurveyQuestionsTable is an internal type.

    <control type="SurveyQuestionsTable">

When the SurveyControl is created, it should create a corresponding DataMapper of a type specified by the name attribute of the datamapper child element.

DataMapper class names should end with "Mapper". The code below instructs the framework to create a datamapper of type Page1Mapper, which in our example is of type SurveyQuestionTableMapper<Page1>

If the datamapper element is not present, no datamapper will be created, and the Load/Save operations will not be called on postback. This can be useful for prototyping the displayed controls, as a datamapper class does not have to be created, and no UI-object mapping will be performed.

      <datamapper name="Page1"></datamapper>

The configuration child element is also parsed by the SurveyControl. By convention, configuration elements are always passed down to the classes that are created by the parent class. In the case of SurveyQuestionsTable, each questions element in the configuration creates an instance of a class that should inherit from the SQRow abstract class.

You will notice that the built in SQRow types require "SQ" to be prefixed to the class name. This is to avoid ambiguity between the System.Web.UI.WebControls types. In the XML however, the SQ prefix should not be present, leading us to the following configuration:

        <question type="TextBox" id="TextVal">
          <text>This is a TextBox:</text>
        <question type="TextBox" id="NumberVal" datatype="integer">
          <text>This is a numeric TextBox:</text>
        <question type="YesNo" id="YesNoVal">
          <text>This is a Yes/No radiobutton group:</text>

As you may have guessed, there is an SQTextBox class and a SQYesNo class.

Last edited Jul 9, 2012 at 12:37 AM by RupertAvery, version 1


No comments yet.