title: Modal Popup closes on Postback
body: <p>There popup modal which has different pizza sizes as radio button and bellow that a select flavor List Box which shows flavor according to the sizes. I want to show flavor according to sizes on selected change of radio button. But the popup modal closes. I tried it with jquery and also  ScriptManager and UpdatePanel but it then don't allow to select other sizes only default is selected (small size is selected).</p>
  
  <hr>
  
  <h2>ASP.Net</h2>
  
  <pre><code>&lt;head&gt;
  &lt;body&gt;
  &lt;form&gt;
  
    &lt;a href="#" data-toggle="modal" data-target="#pizzaModal"&gt;
     &lt;p&gt;Pizza&lt;/p&gt;
    &lt;img src="../dist/img/dashboardIcons/pizza.png" width="70" height="70" /&gt;
    &lt;div class="modal fade" id="pizzaModal"&gt;
    &lt;div class="modal-dialog"&gt;
    &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
        &lt;button type="button" class="close" data-dismiss="modal" aria- 
          label="Close"&gt;
           &lt;/button&gt;
         &lt;/div&gt;
  
  &lt;div class="modal-body"&gt;
  
   &lt;div class="row-fluid"&gt;
       &lt;div class="card card-danger"&gt;
       &lt;div class="card-header"&gt;
        &lt;h3 class="card-title"&gt;Select Size&lt;/h3&gt;
        &lt;/div&gt;
  
       &lt;asp:RadioButtonList ID="RadioButtonList1" runat="server" 
     RepeatDirection="Horizontal" 
  OnSelectedIndexChanged="rblPizza_SelectedIndexChanged" AutoPostBack="true"&gt; 
      &lt;/asp:RadioButtonList&gt;
  
    &lt;/div&gt;
    &lt;/div&gt;
  
    &lt;h3 class="card-title"&gt;Select Flavour&lt;/h3&gt;
    &lt;/div&gt;
     &lt;div class="card-body"&gt;
  &lt;asp:ListBox runat="server" ID="ListBox1" SelectionMode="Multiple"&gt; 
  &lt;/asp:ListBox&gt;
  &lt;/div&gt;
  &lt;div class="modal-footer"&gt;
   &lt;button type="button" class="btn btn-primary" id="btnSavePizza"&gt;Save 
    changes&lt;/button&gt;
   &lt;/div&gt;
   &lt;/div&gt;
  
       &lt;/div&gt;
  
      &lt;/div&gt;
  &lt;/form&gt;
   &lt;/body&gt;
   &lt;/head&gt;
  </code></pre>
  
  <h2>## Backend Code ##</h2>
  
  <pre><code>enter code here
  
  protected void Page_Load(object sender, EventArgs e)
  {
  if (!this.IsPostBack)
      {
          string pizzaModal = lblPizzaModal.Text;
  
          if (pizzaModal != "" &amp;&amp; pizzaModal != null)
          {
              BindSizeList(pizzaModal, rblPizza);
              BindFlavourList(pizzaModal, lstBoxPizzaFlavour);
          }
      }
  
  else
      {
          int a = 10;
         //need to stop modal from closing in this section
  
      }
  }
  
   protected void rblPizza_SelectedIndexChanged(object sender, EventArgs e)
  {
      SqlConnection con = new 
     SqlConnection(ConfigurationManager.ConnectionStrings["DBCON"].ToString());
  
      SqlCommand command = new SqlCommand("sp_SelectProductFlavourSize", con);
      command.CommandType = CommandType.StoredProcedure;
      command.Parameters.AddWithValue("@SizeId", 1);
  
      con.Open();
      SqlDataAdapter adpt = new SqlDataAdapter(command);
      DataSet ds = new DataSet();
  
      adpt.Fill(ds);
      lstBoxPizzaFlavour.DataSource = ds;
      lstBoxPizzaFlavour.DataTextField = "Name";
      lstBoxPizzaFlavour.DataValueField = "FlavourId";
      lstBoxPizzaFlavour.DataBind();
      con.Close();
     }
  </code></pre>