<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <telerik:RadGrid runat="server" AutoGenerateEditColumn="true" AllowFilteringByColumn="true" ID="RadGrid1" AutoGenerateColumns="false">
        <MasterTableView DataKeyNames="ID">
            <Columns>
                <telerik:GridBoundColumn DataField="ID" HeaderText="ID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Item" HeaderText="Item">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Date" HeaderText="Date">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn UniqueName="MytemplateColumn">
                    <ItemTemplate>
                        <asp:Button Text="GetDataFromWebService" ID="Button1" runat="server" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <telerik:RadCodeBlock runat="server">
        <script type="text/javascript">
            function btnAddClick(id) {

                var webMethod = "WebService.asmx/InsertBasket";
                var SenderType = 1;
                var SenderId = 22;
                var ProductId = 333;
                var CustomerId = 99;
                var SalesmanId = 88;
                var DiscSpecial = 23;
                var TerminalNumber = 234;

                var parameters = "{'SenderType':'" + SenderType + "', 'SenderId':'" +
                    SenderId + "', 'ProductId':'" + ProductId + "', 'CustomerId':'" +
                    CustomerId + "', 'SalesmanId':'" + SalesmanId + "', 'Quantity':'" +
                    22 + "','DiscSpecial':'" + DiscSpecial + "','TerminalNumber':'" +
                    TerminalNumber + "'}";

                $.ajax({
                    type: "POST",
                    url: webMethod,
                    data: parameters,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: OnGetSuccess,
                    error: OnGetError
                });
            }

            function OnGetSuccess(data) {
                alert("OnGetSuccess");
            }

            function OnGetError(e) {
                alert("OnGetError");
            }

        </script>
    </telerik:RadCodeBlock>
</asp:Content>
