<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadGridWithEditUserControl.aspx.cs"
    Inherits="RadGridWithEditUserControl" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

        <script type="text/javascript">
            function centerUpdatePanel() {
           centerElementOnScreen(document.getElementById("<%=RadAjaxLoadingPanel1.ClientID %>"));
       }
       function centerElementOnScreen(element)
       {
        var scrollTop = document.body.scrollTop;
        var scrollLeft = document.body.scrollLeft;
        var viewPortHeight = document.body.clientHeight;
        var viewPortWidth = document.body.clientWidth;
        if (document.compatMode == "CSS1Compat")
        {
         viewPortHeight = document.documentElement.clientHeight;
         viewPortWidth = document.documentElement.clientWidth;
         scrollTop = document.documentElement.scrollTop;
         scrollLeft = document.documentElement.scrollLeft;
        }
        var topOffset = Math.ceil(viewPortHeight/2 - element.offsetHeight/2);
        var leftOffset = Math.ceil(viewPortWidth/2 - element.offsetWidth/2);
        var top = scrollTop + topOffset - 40;
        var left = scrollLeft + leftOffset - 70;
           element.style.position = "absolute";
        element.style.top = top + "px";
        element.style.left = left + "px";
        }
        </script>

    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <ClientEvents OnRequestStart="centerUpdatePanel();" />
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="175px"
        Transparency="20" Width="175px" IsSticky="true">
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
            style="border: 0px; "'" />
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="false" Skin="Vista" GridLines="None" OnNeedDataSource="RadGrid1_NeedDataSource"
        OnPreRender="RadGrid1_PreRender" OnInsertCommand="RadGrid1_InsertCommand" OnItemCommand="RadGrid1_ItemCommand"
        OnItemDataBound="RadGrid1_ItemDataBound" OnItemCreated="RadGrid1_ItemCreated">
        <MasterTableView DataKeyNames="CustomerID" EditMode="PopUp" EnableNoRecordsTemplate="false"
            CommandItemDisplay="Top">
            <Columns>
                <telerik:GridEditCommandColumn UniqueName="EditColumn1" HeaderText="EditColumn1">
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" UniqueName="CustomerID"
                    SortExpression="CustomerID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" UniqueName="CompanyName"
                    SortExpression="CompanyName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ContactName" HeaderText="ContactName" UniqueName="ContactName"
                    SortExpression="ContactName">
                </telerik:GridBoundColumn>
                <telerik:GridHyperLinkColumn UniqueName="HyperLinkColumn" HeaderText="Link" NavigateUrl="http://www.telerik.com"
                    Text="telerik">
                </telerik:GridHyperLinkColumn>
            </Columns>
            <EditFormSettings UserControlName="EditUserControl.ascx" EditFormType="WebUserControl">
            </EditFormSettings>
        </MasterTableView>
    </telerik:RadGrid>
    <telerik:RadInputManager ID="RadInputManager1" runat="server">
    </telerik:RadInputManager>
    </form>
</body>
</html>
