Note that there are some explanatory texts on larger screens.

plurals
  1. POUPDATE PANEL question
    primarykey
    data
    text
    <p>I have a code that generates a new question based on question type and updates the asp.net update panel with a new question every time user clicks next button My question is how do I get the response of the question user is currently on when I click next. More specifically how do I read previous value from update panel as a next is clicked and a new panel is loaded.</p> <pre><code> public static int incremental = 0; protected void Page_Load(object sender, EventArgs e) { UpdateButton2.Text = "Start the Pre-Assessment"; } protected void UpdateButton_Click(object sender, EventArgs e) { COPDEntities1 copdContext = new COPDEntities1(); UpdateButton2.Text = "NEXT"; var questions = (from p in copdContext.Questions select p).ToList(); if (incremental == questions.Count) { incremental = 0; } DateTimeLabel2.Text = questions[incremental].QuestionText; if (questions[incremental].QuestionAnswerTypeID == 1) { RadioButtonList choices = new RadioButtonList(); choices.ID = "choices"; choices.ID = Convert.ToString(1); choices.Items.Add(new ListItem("True", "0")); choices.Items.Add(new ListItem("False", "1")); pnlChoice.Controls.Add(choices); } if (questions[incremental].QuestionAnswerTypeID == 2) { TextBox text = new TextBox(); text.ID = "choices"; pnlChoice.Controls.Add(text); } if (questions[incremental].QuestionAnswerTypeID == 3) { int questID = questions[incremental].QuestionID; var responses = (from r in copdContext.QuestionResponses where r.QuestionID == questID select r).ToList(); RadioButtonList choices = new RadioButtonList(); choices.ID = "choices"; choices.ID = Convert.ToString(3); foreach(var choice in responses) { int choiceID= choice.ResponseID; var multchoices = (from c in copdContext.Responses where c.ResponseID == choiceID select c).FirstOrDefault(); choices.Items.Add(new ListItem(multchoices.ResponseLongdescription, Convert.ToString(multchoices.ResponseID))); } pnlChoice.Controls.Add(choices); // Label1.Text = Convert.ToString(responses[0].ResponseID); } if (questions[incremental].QuestionAnswerTypeID == 4) { int questID = questions[incremental].QuestionID; var responses = (from r in copdContext.QuestionResponses where r.QuestionID == questID select r).ToList(); CheckBoxList choices = new CheckBoxList(); choices.ID = "choices"; choices.ID = Convert.ToString(3); foreach (var choice in responses) { int choiceID = choice.ResponseID; var multchoices = (from c in copdContext.Responses where c.ResponseID == choiceID select c).FirstOrDefault(); choices.Items.Add(new ListItem(multchoices.ResponseLongdescription, Convert.ToString(multchoices.ResponseID))); } pnlChoice.Controls.Add(choices); } if (questions[incremental].QuestionAnswerTypeID == 5) { TextBox text = new TextBox(); text.ID = "choices"; pnlChoice.Controls.Add(text); } if (questions[incremental].QuestionAnswerTypeID == 6) { } if (questions[incremental].QuestionAnswerTypeID == 7) { RadioButtonList choices = new RadioButtonList(); } incremental++; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload