title: c# asp.net Form with a submit button and a button that executes a command?
body: <p>basically i have a form with the runat server tag. within this form i have an asp repeater and asubmit button- but i also want to have a button which will call a c# method in my code - can someone please give me an idea as to how to go about this? Also in this code the selectindexchanged event does not fire even though its autopostback value is true which is weird :/</p>
  
  <p>thanks</p>
  
  <p><strong>Edit</strong>
  OK solution seems to be remove the action tab and i have then set the property through some JavaScript instead :) why cant things be straightforward </p>
  
  <hr>
  
  <pre><code>    &lt;form action="broadcast.aspx" id="bcForm" runat="server" onsubmit="chkChecks()"&gt; 
              &lt;a class="btn btn-warning" href="#" title="Create new product"&gt; &lt;i class="icon-plus icon-white"&gt;&lt;/i&gt; Create new product&lt;/a&gt; &amp;nbsp &amp;nbsp &lt;a id="bcItems" data-toggle="modal" class="btn btn-primary" title="Broadcast" onclick="chkItems()"&gt;&lt;i class="icon-share icon-white"&gt;&lt;/i&gt; Broadcast&lt;/a&gt;
  
  &lt;/br&gt;&lt;/br&gt;
  &lt;p&gt;Filters:
  &lt;asp:DropDownList ID="groupFilter" runat="server" ToolTip="Groups"        AutoPostBack="True" onselectedindexchanged="groupFilter_SelectedIndexChanged1" &gt;&lt;/asp:DropDownList&gt;&lt;/p&gt;
  
  
     &lt;div&gt;
          &lt;asp:Repeater ID="DepartmentList" runat="server"  OnItemmDataBound="DepartmentsList_ItemDataBound"&gt;
     &lt;HeaderTemplate&gt;
           &lt;table id="grouptable" class="table table-bordered table-striped sortable"&gt; 
                      &lt;thead&gt;
                              &lt;tr&gt;
                              &lt;th class="sorttable_nosort" &gt;Broadcast 
                                  &lt;br&gt; &lt;/br&gt;&lt;a class="label label-inverse" onclick="checkAll()"&gt;Check All&lt;/a&gt;&amp;nbsp&lt;a class="label label-inverse" onclick="uncheckAll()"&gt;Uncheck All&lt;/a&gt;&lt;/th&gt;
                              &lt;th class="sorttable_numeric"&gt;ID&lt;/th&gt;
                              &lt;th&gt;Name&lt;/th&gt;
                              &lt;th&gt;Last Modified&lt;/th&gt;
                              &lt;th&gt;Actions&lt;/th&gt;
                          &lt;/tr&gt;
                          &lt;/thead&gt;
                          &lt;tbody&gt;
                  &lt;/HeaderTemplate&gt;
                  &lt;ItemTemplate&gt;
                              &lt;tr&gt;
                              &lt;td WIDTH="100"&gt;
                              &lt;input type="checkbox" name="BroadcastSelect[]" value="&lt;%# Eval("DEPT_ID") %&gt;"&lt;/input&gt;&lt;/td&gt;
                              &lt;td&gt;
                                  &lt;asp:Label ID="Label1" runat="server" Text='&lt;%# Eval("DEPT_ID") %&gt;'&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;%# Eval("DESC") %&gt;&lt;/td&gt;
                              &lt;td&gt;
                                  &lt;asp:Label ID="Label2" runat="server" Text='&lt;%# Eval("CHG_DATE") %&gt;'&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;a class="btn btn-info" href="&lt;%# Eval("gURL") %&gt;"&gt;Edit&lt;/a&gt;&amp;nbsp;&amp;nbsp&lt;asp:HyperLink ID="HyperLink1" runat="server" CssClass="btn btn-danger"&gt;Broadcast Now&lt;/asp:HyperLink&gt;&lt;/td&gt;
                              &lt;/tr&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;FooterTemplate&gt;
                              &lt;/tbody&gt;
                      &lt;/table&gt;
                  &lt;/FooterTemplate&gt;
                  &lt;/asp:Repeater&gt;
                  &lt;/div&gt;
  
  
  
                &lt;div id="myModal" class="modal hide fade" runat="server"&gt;
                  &lt;div class="modal-header"&gt;
                    &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times; Select A Branch&lt;/h3&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt;
                    &lt;h4&gt;Test&lt;/h4&gt;
  
                  &lt;asp:Repeater ID="cfgList" runat="server"&gt;
                      &lt;HeaderTemplate&gt;
                     &lt;table id="configtable" class="table table-bordered table-striped"&gt; 
                      &lt;thead&gt;
                              &lt;tr&gt;
                              &lt;th&gt;Broadcast&lt;/th&gt;
                              &lt;th&gt;Branch No.&lt;/th&gt;
                              &lt;th&gt;Branch Name&lt;/th&gt;
                          &lt;/tr&gt;
                          &lt;/thead&gt;
                          &lt;tbody&gt;
                  &lt;/HeaderTemplate&gt;
                  &lt;ItemTemplate&gt;
                              &lt;tr&gt;
                              &lt;td&gt;
                              &lt;input type="checkbox" name="BranchSelection[]" value="&lt;%# Eval("branch") %&gt;"&lt;/input&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;%# Eval("branch") %&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;%# Eval("name") %&gt;&lt;/a&gt; &lt;/td&gt;
                              &lt;/tr&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;FooterTemplate&gt;
                              &lt;/tbody&gt;
                      &lt;/table&gt;
                  &lt;/FooterTemplate&gt;
                  &lt;/asp:Repeater&gt;
  
  
                  &lt;/div&gt;
  
                  &lt;div class="modal-footer"&gt;
                    &lt;!--&lt;a class="btn btn-success" onclick="document.getElementById('bcForm').submit()" title="Broadcast"&gt;&lt;i class="icon-share icon-white"&gt;&lt;/i&gt; Broadcast&lt;/a&gt; --&gt;
                    &lt;a class="btn btn-success" onclick="chkBranches()" title="Broadcast"&gt;&lt;i class="icon-share icon-white"&gt;&lt;/i&gt; Broadcast&lt;/a&gt;
                    &lt;!--&lt;input type="submit" value="Broadcast3" class="btn btn-success"/&gt; --&gt;
                    &lt;div id="myDiv"&gt;&lt;/div&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
                &lt;!-- &lt;a data-toggle="modal" href="#myModal" class="btn btn-primary"&gt;Broadcast Testing&lt;/a&gt; --&gt;
                  &lt;!--&lt;a class="btn btn-success" onclick="document.getElementById('bcForm').submit()" title="Broadcast"&gt;&lt;i class="icon-share icon-white"&gt;&lt;/i&gt; Broadcast&lt;/a&gt;--&gt;
                  &lt;a id="bcItems2" data-toggle="modal" class="btn btn-primary" title="Broadcast" onclick="chkItems()"&gt;&lt;i class="icon-share icon-white"&gt;&lt;/i&gt; Broadcast&lt;/a&gt;
                  &lt;ul class="pager"&gt;
                  &lt;li&gt;
                  &lt;asp:Button ID="previousBtn" runat="server" Text="Prev" cssclass="search-query" 
                          Width="80px"/&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                  &lt;asp:Button ID="nextBtn" runat="server" Text="Next" cssclass="search-query" 
                          Width="80px"/&gt;
                  &lt;/li&gt;
                  &lt;/ul&gt;
                  &lt;/form&gt;
  </code></pre>