title: asp:ModalPopupExtender button causing postback on main page
body: <p>I have a page that I am trying to use the asp:ModalPopupExtender on.  I am using the popup as a seach tool so it has a user control with a textbox, a search button, a gridview and an ok button.  When the user enters a search term and clicks the Search button, a postback is occuring that is causing the popup to close.  I don't waht the popup to close until the user clicks the Ok button. I can use the popup exactly as is on a simple page that has no other functionality and it works just fine.  I'm a little stumped.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Here is the code on the page that contains the popup.</p>
  
  <pre><code>&lt;asp:Panel ID="ApplicationPicker" runat="server" CssClass="hidden"&gt;
                                                  &lt;asp:Button ID="Button1" runat="server" Text="Search for Application" /&gt;
                                                  &lt;asp:Label ID="ApplicationID" runat="server"&gt;&lt;/asp:Label&gt;
                                                  &lt;asp:Panel ID="Panel1" runat="server" CssClass="modalBackground" style="display:none;"&gt; 
                                                      &lt;appPicker:ApplicationPicker ID="thisAppPicker" runat="server" /&gt;
                                                      &lt;asp:Button ID="btnOk" runat="server" Text="Ok" OnClick="OkButton_Clicked" /&gt; 
                                                  &lt;asp:Button ID="btnClose" runat="server" Text="Close Me" /&gt; 
                                                  &lt;/asp:Panel&gt; 
  
                                                  &lt;asp:ModalPopupExtender 
                                                  DropShadow="true" 
                                                  CancelControlID="btnClose" 
                                                  runat="server" 
                                                  PopupControlID="Panel1" 
                                                  id="ModalPopupExtender1" 
                                                  TargetControlID="Button1" /&gt; 
                                              &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>Here is the application picker user control.  The whole thing is inside an update panel but for some reason this editor was messing up the code format with the update panel in it.</p>
  
  <pre><code>&lt;asp:Panel ID="pDelegateBody" BackColor="White" runat="server"&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;asp:Label CssClass="indentedTextBold" ID="ApplicationSearchLabel" runat="server" Text="Search for:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;asp:TextBox ID="txtSearch" runat="server" Width="300px" Visible="true" /&gt;&lt;asp:Label ID="ValidationLabel" runat="server" Text="Please enter at least 3 characters to search." ForeColor="Red" Visible="false"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
  
          &lt;td&gt;&lt;asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="Buttons" onclick="Search_Click" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td colspan="4"&gt;
          &lt;asp:Panel ID="PanelProjectPicker" runat="server" Height="220px" Width="600px" ScrollBars="Vertical" BorderStyle="Solid" BorderWidth="1" BorderColor="GrayText"&gt;
              &lt;telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="False" 
                  AutoGenerateColumns="False" CellPadding="0" DataKeyNames="LANID" 
                  EnableEmbeddedSkins="false" onitemcommand="RadGrid1_ItemCommand" 
                  ShowHeader="true" Skin="WF" ViewStateMode="Enabled" Width="580px" ClientIDMode="AutoID"&gt;
                  &lt;MasterTableView Font-Size="X-Small"&gt;
                      &lt;Columns&gt;
                          &lt;telerik:GridBoundColumn DataField="ApplicationID" HeaderText="ID" Visible="False" /&gt;
                          &lt;telerik:GridBoundColumn DataField="Name" HeaderText="Display Name" SortExpression="DISPLAY_NAME" /&gt;
                      &lt;/Columns&gt;
                  &lt;/MasterTableView&gt;
                  &lt;ClientSettings EnablePostBackOnRowClick="true" EnableRowHoverStyle="True"&gt;
                      &lt;Selecting AllowRowSelect="true" /&gt;
                  &lt;/ClientSettings&gt;
                  &lt;HeaderStyle BackColor="#666666" Font-Names="verdana, arial" Font-Size="Small" 
                      Height="20px" /&gt;
              &lt;/telerik:RadGrid&gt;
          &lt;/asp:Panel&gt;
          &lt;asp:Label ID="appID" runat="server"&gt;&lt;/asp:Label&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p></p>
  
  <p>and here is the code behind for the application picker</p>
  
  <pre><code>protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
      {
          if (e.CommandName == "RowClick")
          {
              GridDataItem item = RadGrid1.Items[e.Item.ItemIndex];
              appID.Text = item["ApplicationID"].Text;
          }
      }
      protected void loadData()
      {
          if (Session["User"] != null)
          {
              currentUser = (User)Session["User"];
          }
  
          if (txtSearch.Text != "" &amp;&amp; txtSearch.Text.Length &gt; 2)
          {
              List&lt;Application&gt; AllApplications = new List&lt;Application&gt;();
  
              if (UserController.IsUserWOT((User)Session["User"]))
              {
                  AllApplications = BusinessUtility.GetApplications();
              }
              else
              {
                  AllApplications = BusinessUtility.GetApplicationsByManagerLanId(currentUser.LanID);
              }
  
              List&lt;Application&gt; filteredApplications = new List&lt;Application&gt;();
  
              filteredApplications = AllApplications.Where(x =&gt; x.Name.ToString().ToUpper().Contains(txtSearch.Text.ToUpper())).ToList();
  
              if (filteredApplications.Count &gt; 0)
              {
                  RadGrid1.DataSource = filteredApplications;
                  RadGrid1.DataBind();
              }
          }
      }
  
      protected void Search_Click(object sender, EventArgs e)
      {
          if (txtSearch.Text.Length &lt; 3)
          {
              ValidationLabel.Visible = true;
          }
          else
          {
              ValidationLabel.Visible = false;
              RadGrid1.DataSource = "";
              RadGrid1.DataBind();
              loadData();
              PanelProjectPicker.Visible = true;
          }
      }
  </code></pre>