Including Code Snippets In Blogger

Writing code snippets in Blogger is a real task, for which I found the following site extremely useful:

SimpleCode

Just copy the code and paste it in the first text area and click Process. Then paste the code from the lower text area into your Blogger post, wherever necessary. :)

Although the code, when pasted, may be maroon in colour, you can change it according to what you like.



Comments

  1. private void PopulateSurvey()
    {
    btnSubmit.Enabled = true;
    List questions = (from p in context.Questions
    join q in context.SurveyQuestions on p.ID equals q.QuestionID
    where q.SurveyID == surveyid
    select p).ToList();
    Table tbl = new Table();
    tbl.Width = Unit.Percentage(100);
    TableRow tr;
    TableCell tc;
    TextBox txt;
    CheckBox cbk;
    DropDownList ddl;

    foreach (Question q in questions)
    {
    tr = new TableRow();
    tc = new TableCell();
    tc.Width = Unit.Percentage(25);
    tc.Text = q.Text;
    tc.Attributes.Add("id", q.ID.ToString());
    tr.Cells.Add(tc);
    tc = new TableCell();

    if (q.QuestionType.ToLower() == "singlelinetextbox")
    {
    txt = new TextBox();
    txt.ID = "txt_" + q.ID;
    txt.Width = Unit.Percentage(40);
    tc.Controls.Add(txt);
    }

    if (q.QuestionType.ToLower() == "multilinetextbox")
    {
    txt = new TextBox();
    txt.ID = "txt_" + q.ID;
    txt.TextMode = TextBoxMode.MultiLine;
    txt.Width = Unit.Percentage(40);
    tc.Controls.Add(txt);
    }

    if (q.QuestionType.ToLower() == "singleselect")
    {
    ddl = new DropDownList();
    ddl.ID = "ddl_" + q.ID;
    ddl.Width = Unit.Percentage(41);
    if (!string.IsNullOrEmpty(q.Options))
    {
    string[] values = q.Options.Split(',');
    foreach (string v in values)
    ddl.Items.Add(v.Trim());
    }
    tc.Controls.Add(ddl);
    }
    tc.Width = Unit.Percentage(80);
    tr.Cells.Add(tc);
    tbl.Rows.Add(tr);
    }
    pnlSurvey.Controls.Add(tbl);
    }

    ReplyDelete

Post a Comment