リストビューがあります。編集、更新、削除をクリックしたときにページが何度も読み込まれないようにしたいです。編集をクリックして行を編集すると、ページはポストバックを実行します。ポストバックを実行しないために何をする必要がありますか。
My code is
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "TestOrigin.aspx/BindDatatable",
data: "{}",
dataType: "json"
});
});
</script>
<script type="text/javascript">
function javascriptfunction()
{
return false;
}
</script>
<asp:ListView ID="lstOrigin"
runat="server"
ItemPlaceholderID="PlaceHolder1" OnItemEditing="EditListViewItem"
OnItemCanceling="CancelListViewItem"
OnItemUpdating="UpdateListViewItem"
OnItemInserting="InsertListViewItem"
InsertItemPosition="LastItem" OnItemDeleting="DeleteListViewItem"
DataKeyNames="ID" >
<LayoutTemplate>
<table width="100%" cellpadding="4" cellspacing="0">
<tr class="header">
<th >
<asp:LinkButton ID="lnkID" runat="server" CommandName="Sort"
CommandArgument="ID" Text="ID" />
</th>
<th >
<asp:LinkButton ID="lnkaddress" runat="server"
CommandName="Sort" CommandArgument="Address" Text="Address" />
</th>
<th >
<asp:LinkButton ID="lnkpin" runat="server" CommandName="Sort"
CommandArgument="Pin" Text="Pin" />
</th>
<th >
<asp:LinkButton ID="lnkcity" runat="server" CommandName="Sort"
CommandArgument="City" Text="City" />
</th>
<th>
<asp:LinkButton ID="lnkstate" runat="server" CommandName="Sort"
CommandArgument="State" Text="State" />
</th>
<th>
<asp:LinkButton ID="lnkcountry" runat="server" CommandName="Sort"
CommandArgument="Country" Text="Country" />
</th>
<th>
<asp:LinkButton ID="lnkport" runat="server" CommandName="Sort"
CommandArgument="Port" Text="Port" />
</th>
<th>
<asp:LinkButton ID="lnkoutsource" runat="server" CommandName="Sort"
CommandArgument="Outsourcing" Text="Outsourcing" />
</th>
<th>
Modify
</th>
</tr>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr class="item">
<td>
<%# Eval("ID") %>
</td>
<td>
<%# Eval("Address") %>
</td>
<td>
<%# Eval("Pin") %>
</td>
<td>
<%# Eval("City") %>
</td>
<td>
<%# Eval("State") %>
</td>
<td>
<%# Eval("Country") %>
</td>
<td>
<%# Eval("Port") %>
</td>
<td>
<%# Eval("Outsourcing") %>
</td>
<td>
<asp:Button ID="lnkEdit" runat="server" Text="Edit"
PostBackUrl="~/TestOrigin.aspx" CommandName="Edit" OnClientClick="javascriptfunction"/>
<asp:Button ID="lnkDelete" runat="server" Text="Delete"
CommandName="Delete" ForeColor="Brown" OnClientClick="javascriptfunction"/>
</span>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td>
<%# Eval("ID") %>
</td>
<td>
<%# Eval("Address") %>
</td>
<td>
<%# Eval("Pin") %>
</td>
<td>
<%# Eval("City") %>
</td>
<td>
<%# Eval("State") %>
</td>
<td>
<%# Eval("Country") %>
</td>
<td>
<%# Eval("Port") %>
</td>
<td>
<%# Eval("Outsourcing") %>
</td>
<td>
<asp:Button ID="lnkEdit" runat="server" Text="Edit"
CommandName="Edit" OnClientClick="javascriptfunction" />
<asp:Button ID="lnkDelete" runat="server" Text="Delete"
CommandName="Delete" ForeColor="Brown" OnClientClick="javascriptfunction"/>
</span>
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr class="edititem">
<td>
<asp:TextBox ID="txtID" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:TextBox ID="txtAddress" runat="server" Text='<%#
Eval("Address") %>' />
</td>
<td>
<asp:TextBox ID="txtPin" runat="server" Text='<%# Eval("Pin") %>'
/>
</td>
<td>
<asp:TextBox ID="txtCity" runat="server" Text='<%# Eval("City") %>'
/>
</td>
<td>
<asp:TextBox ID="txtState" runat="server" Text='<%# Eval("State")
%>' />
</td>
<td>
<asp:TextBox ID="txtCountry" runat="server" Text='<%#
Eval("Country") %>' />
</td>
<td>
<asp:TextBox ID="txtPort" runat="server" Text='<%# Eval("Port") %>'
/>
</td>
<td>
<asp:TextBox ID="txtOutsource" runat="server" Text='<%#
Eval("Outsourcing") %>' />
</td>
<td>
<asp:Button ID="btnUpdate" runat="server" Text="Update"
CommandName="Update" OnClientClick=" javascriptfunction" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel"
CommandName="Cancel" OnClientClick=" javascriptfunction" />
</td>
</tr>
</EditItemTemplate>
</EmptyDataTemplate>
</asp:ListView>