title: dropdownlist postback (different prob)
body: <p>hi guys i have a weird prob here..
  i have this dropdownlist where different values will hide/show some of the textbox in the page</p>
  
  <pre><code> &lt;asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"&gt;
                &lt;asp:ListItem&gt;Multiple Choice Question&lt;/asp:ListItem&gt;
                &lt;asp:ListItem&gt;Free text answer&lt;/asp:ListItem&gt;
                              &lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>C# code behind, inside <code>Page_Load</code>:</p>
  
  <pre><code>   if (Page.IsPostBack)
      {
          if (DropDownList1.SelectedValue == "Multiple Choice Question")
          {
              tb_ans.Visible = true;
              tb_ans2.Visible = true;
          }
          else
          {
              tb_ans2.Visible = false;
              tb_ans.Visible = false;
          }
      }
      if (!Page.IsPostBack) //the code within this statement will only load
      {
          Session["no"] = null;
          this.opt3.Attributes["style"] = "display: none;";
          .....
          opt3.Visible = false;
          ....
      }
  </code></pre>
  
  <p>Tried to debug and the result was : (i set breakpoint in page load)
  when i select different value from the dropdownlist.
  3rd time on changing the value, it looks like the dropdownlist keep the same value as the 2nd value. </p>
  
  <p>the loop always go to the if(ddl.selectedvalue=="multiple...")
  . As a result, it will not hide the textbox that i want if the value is change to "free text..."</p>
  
  <p>example :</p>
  
  <ol>
  <li><p>default selection 'multiple choice..'</p></li>
  <li><p>change to 'free ans..' will hide the textbox but other button is not firing.</p></li>
  <li><p>change back to 'multiple choice...' it will turn back to 'free ans..'</p></li>
  <li><p>ddl.selected value is still multiple choice.</p></li>
  </ol>
  
  <p>what is the problem here.. </p>