[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

asp.net, c#

I have a project to build web-based survey app. in asp.net c#, In  the survey, there is over 200 questions, so step by step application is required.

1. in asp.net world, what is the best approach to create the codes? using wizard, panel? or 3rd party solution? Remember, the user should be able to update after the survey is completed.

2. Saving the data into the database is another issue. Since there is so many data for each columns. I am trying to find a better solution instead of creating 200+ columns for the tables.

My approach is getting all of the information and create xml string like.
<survey id=1>

And save the xml string into the database.

However, I need some idea how to code in the frontend aspx/c#. Like create a session to store xml string during the step by step procedures....or other.

I hope experts can give me some idea how to generate the xml string
and be able to update xml string after the survey is completed.

Sound complex but actually it happens all the time in the real world app. If you need any third party asp.net component that working ... please let me know
1 Solution
Chinmay PatelEnterprise ArchitectCommented:

You can acheive this task with minimal code.

Go through these articles which is the solution for your requirement:



This kind of thing is very easy in asp.net.   You don't have to create the session, it is already there.  You can store information for the current user session without effort just by saying Session["field name"] = value;

There are classes built in to the common library that handle the creation of xml, updating databases, and make it easy to get data from the database to the user interface and back again with a minimum amount of effort.  Of course, there is a learning curve, and you have to learning the techniques.  

If your user has been through a login process, I would collect the answers in a database so they can continue where they left off.  If the user is anonymous (and it sounds like that is the case), then just use the current session to collect the data.

Here is a c# code snippet that builds xml.  There are lots of ways to do it, some more advanced than others and some are not available in all versions of .Net.  

 XmlDocument doc = new XmlDocument();            
 XmlElement root = CreateElement(doc,"root");            
 XmlElement xFirstName = CreateElement(doc,"firstName");

and there are methods to add children, attributes, inner text, etc.  

Here is one way to convert that document to a string.

public static string StringFromXmlDocument(XmlDocument xmlDoc)
            StringWriter sw = new StringWriter();
            XmlTextWriter xw = new XmlTextWriter(sw);
            xw.Formatting = Formatting.Indented;
            return sw.ToString();

Which aspect do you want to work on first, populating the data from the XML string into the UI,  creating the XML string from the UI, or storing and retrieiving the XML string to/from the DB?

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now