Esempio n. 1
0
        // this function renders the form and it's questions
        public void renderForm(cForm form)
        {
            // get questions from form
            cQuestions questions = form.Questions;

            // render form name and info
            Response.Write("<h2>" + form.Name + "</h2><h5>" + form.Info + "</h5>");

            // render questions
            int j = 0;

            foreach (var i in questions)
            {
                Response.Write("<div class='form-view-question'>");
                Response.Write("<div class='question'>" + i.Text + "</div><div class='infotext'>" + i.Info + "</div>");
                switch (i.Type)
                {
                case "text": Response.Write("<input type='text' id='q" + j + "' name='q" + j + "' maxlength='150' />");
                    break;

                case "textarea": Response.Write("<textarea id='q" + j + "' name='q" + j + "' rows='2' cols='70' maxlength='255'></textarea>");
                    break;
                }
                Response.Write("</div>");
                j++;
            }
            Response.Write("<input type='hidden' name='insert' value='make' />");
            // render save entry submit button and back button
            Response.Write("<input type='submit' id='submitentry' name='submitentry' value='Save' class='button form-view-button' />&nbsp;<input type='button' class='button form-view-button' value='Cancel' onclick='window.location.href=&#39Create.aspx&#39' />");
        }
Esempio n. 2
0
        protected void btnCreateForm_Click(object sender, EventArgs e)
        {
            // get the list of post data
            List <string> list = new List <string>();

            foreach (string i in Request.Form)
            {
                list.Add(Request.Form[i]);
            }

            // get rid of viewstate and hidden input field values
            for (int i = 0; i < 2; i++)
            {
                list.RemoveAt(0);
            }

            // create form object and set name and info field values
            form      = cMain.newForm();
            form.Name = list[0].Trim();
            form.Info = list[1].Trim();

            // persist form
            if (form.persist())
            {
                // get question names and question info field values
                for (int i = 2, until = list.Count - 1; i < until; i += 3)
                {
                    if (!form.addQuestion(list[i], list[i + 1], list[i + 2]))
                    {
                        setErrorMessage("Error while saving Form!");
                        break;
                    }
                }
                // redirect
                Session["message"] = convertSuccessMessage();
                Response.Redirect("Create.aspx");
            }
            else
            {
                setErrorMessage("Error while saving Form!");
            }
        }
Esempio n. 3
0
 // grab the GET parameter with form id and validate form id
 public void initFormSet()
 {
     try {
         if (Request.QueryString["form"].Length != 0)
         {
             form = cMain.getForm(Request.QueryString["form"]);
             if (form.ID.Length != 0)
             {
                 formset = true;
             }
             else
             {
                 formset = false;
             }
         }
         else
         {
             formset = false;
         }
     }
     catch { formset = false; }
 }