title: how to prevent postback on click of button in listview
body: <p>I have a listview.I want to prevent loading of page again and again on click of edit,update and delete. When i click on edit to edit a row the page performs postback.So what i need to do in order to perform no postback.</p>
  
  <pre><code>My code is
  
  
       &lt;script type="text/javascript"&gt;
      $(document).ready(function() {
      $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "TestOrigin.aspx/BindDatatable",
      data: "{}",
      dataType: "json"
  
      });
      });
      &lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  
      function javascriptfunction()
      {
      return false;
      }
      &lt;/script&gt;
  
  
  &lt;asp:ListView ID="lstOrigin" 
                          runat="server"  
  
    ItemPlaceholderID="PlaceHolder1" OnItemEditing="EditListViewItem" 
          OnItemCanceling="CancelListViewItem"
           OnItemUpdating="UpdateListViewItem" 
           OnItemInserting="InsertListViewItem"
          InsertItemPosition="LastItem" OnItemDeleting="DeleteListViewItem" 
  DataKeyNames="ID" &gt;
  
          &lt;LayoutTemplate&gt;
              &lt;table width="100%" cellpadding="4" cellspacing="0"&gt;
                  &lt;tr class="header"&gt;
                     &lt;th &gt;
                          &lt;asp:LinkButton ID="lnkID" runat="server" CommandName="Sort" 
  CommandArgument="ID" Text="ID"   /&gt;
                      &lt;/th&gt;
                      &lt;th &gt;
                          &lt;asp:LinkButton ID="lnkaddress" runat="server"   
   CommandName="Sort" CommandArgument="Address" Text="Address"  /&gt;
                      &lt;/th&gt;
                      &lt;th &gt;
                          &lt;asp:LinkButton ID="lnkpin" runat="server" CommandName="Sort"  
  
  
  CommandArgument="Pin" Text="Pin" /&gt;
                      &lt;/th&gt;
                      &lt;th &gt;
                          &lt;asp:LinkButton ID="lnkcity" runat="server" CommandName="Sort"  
  CommandArgument="City" Text="City"  /&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                      &lt;asp:LinkButton ID="lnkstate" runat="server" CommandName="Sort" 
  CommandArgument="State" Text="State" /&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                      &lt;asp:LinkButton ID="lnkcountry" runat="server" CommandName="Sort"   
  
   CommandArgument="Country" Text="Country"  /&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                      &lt;asp:LinkButton ID="lnkport" runat="server" CommandName="Sort" 
   CommandArgument="Port" Text="Port" /&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                      &lt;asp:LinkButton ID="lnkoutsource" runat="server" CommandName="Sort" 
  
  CommandArgument="Outsourcing" Text="Outsourcing" /&gt;
                      &lt;/th&gt;
                      &lt;th&gt;
                          Modify
                      &lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;asp:PlaceHolder ID="PlaceHolder1" runat="server"&gt;&lt;/asp:PlaceHolder&gt;
              &lt;/table&gt;
          &lt;/LayoutTemplate&gt;
          &lt;ItemTemplate&gt;
              &lt;tr class="item"&gt;
              &lt;td&gt;
              &lt;%# Eval("ID") %&gt;
              &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("Address") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("Pin") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("City") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("State") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("Country") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("Port") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("Outsourcing") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:Button ID="lnkEdit" runat="server" Text="Edit"    
  PostBackUrl="~/TestOrigin.aspx" CommandName="Edit" OnClientClick="javascriptfunction"/&gt;
  
                          &lt;asp:Button ID="lnkDelete" runat="server" Text="Delete" 
  CommandName="Delete" ForeColor="Brown" OnClientClick="javascriptfunction"/&gt;
                      &lt;/span&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/ItemTemplate&gt;
          &lt;AlternatingItemTemplate&gt;
              &lt;tr&gt;
              &lt;td&gt;
               &lt;%# Eval("ID") %&gt;
              &lt;/td&gt;
                 &lt;td&gt;
                      &lt;%# Eval("Address") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("Pin") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("City") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("State") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("Country") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("Port") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;%# Eval("Outsourcing") %&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:Button ID="lnkEdit" runat="server" Text="Edit" 
  CommandName="Edit" OnClientClick="javascriptfunction" /&gt;
  
                          &lt;asp:Button ID="lnkDelete" runat="server" Text="Delete" 
  CommandName="Delete" ForeColor="Brown"  OnClientClick="javascriptfunction"/&gt;
                      &lt;/span&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/AlternatingItemTemplate&gt;
          &lt;EditItemTemplate&gt;
              &lt;tr class="edititem"&gt;
  
              &lt;td&gt;
  
                      &lt;asp:TextBox ID="txtID" runat="server" Text='&lt;%# Eval("ID") %&gt;' /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
  
                      &lt;asp:TextBox ID="txtAddress" runat="server" Text='&lt;%# 
  Eval("Address") %&gt;' /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
  
                      &lt;asp:TextBox ID="txtPin" runat="server" Text='&lt;%# Eval("Pin") %&gt;'   
  /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="txtCity" runat="server" Text='&lt;%# Eval("City") %&gt;'  
   /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="txtState" runat="server" Text='&lt;%# Eval("State")   
  %&gt;' /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="txtCountry" runat="server" Text='&lt;%# 
  Eval("Country") %&gt;' /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="txtPort" runat="server" Text='&lt;%# Eval("Port") %&gt;'   
  /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="txtOutsource" runat="server" Text='&lt;%# 
  Eval("Outsourcing") %&gt;' /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
  
                          &lt;asp:Button ID="btnUpdate" runat="server" Text="Update" 
  CommandName="Update" OnClientClick=" javascriptfunction" /&gt;
  
                      &lt;asp:Button ID="btnCancel" runat="server"  Text="Cancel"  
  CommandName="Cancel" OnClientClick="  javascriptfunction" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/EditItemTemplate&gt;
  
          &lt;/EmptyDataTemplate&gt;
      &lt;/asp:ListView&gt;
  </code></pre>