Dynamic Data Loading

It’s not required to use physical XML files to display the survey in Survey Viewer Web Control. You can simply set the XML definition of the survey direct to the control without providing any file paths. This would be useful in case that you prefer to store the XML file in other storage source like a database.

You don’t have also to store the response XML in a physical path. You can make use of OnResponseRecieved event to get the response XML and store it in the database as well.

This is a sample of dynamic bending for survey XML definition to the Survey Viewer Web Control without using a physical XML file:

private string xml = @"<survey version='1.2'>
                                <title>Sample Survey</title>
                                <description>This is a sample survey description</description>
                                <endtitle>Thank You</endtitle>
                                <enddescription>Thank you for taking this survey</enddescription>
                                <page id='1' title='Start Page' description='This is a sample start page' />
                                <question id='1' type='singlechoice' page='1'>
                                  <body>What is your gender?</body>
                                  <media />
                                  <rules />

    protected override void OnInit(EventArgs e)
        // Register OnResponseRecieved event of the survey
        this.ucSurveyWebControl.OnResponseRecieved += new

    protected void Page_Load(object sender, EventArgs e)
        // Set the XML definition of the survey
        if (!IsPostBack)
            this.ucSurveyWebControl.Xml = xml;

    protected void ucSurveyWebControl_OnResponseRecieved(object sender, SurveyResponseArgs args)
        // Recieve the XML definition of the response
        string responseXml = args.Xml;        

        //TODO: Save responseXml in your database

See Also