Saturday 10 December 2016

.asp ajax control


without ajax dropdown box cause auto post back which causes screen flicker
with ajax post back is async, no flicker


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Products.aspx.cs" Inherits="InventoryApp.Web.Products" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                 <div>
   
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
             DataSourceID="SupplierSource" DataTextField="Company"
            DataValueField="Id" Height="16px" Width="244px">
        </asp:DropDownList>
        <asp:ObjectDataSource ID="SupplierSource" runat="server" SelectMethod="GetAll"
            TypeName="InventoryApp.Web.Inventory.Services.InventoryServiceClient"></asp:ObjectDataSource>
        <br />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="ProductSource" ForeColor="#333333" GridLines="None" Width="556px" DataKeyNames="Id" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
                <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
                <asp:BoundField DataField="Supplier" HeaderText="Supplier" SortExpression="Supplier" />
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>
        <asp:ObjectDataSource ID="ProductSource" runat="server"
            SelectMethod="GetProductsBySupplier"
            TypeName="InventoryApp.Web.Inventory.Services.InventoryServiceClient">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="id"
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
   
                     <br />
                     <asp:TextBox ID="TextBox1" runat="server" Height="24px" Width="203px" ></asp:TextBox>
                     <ajaxToolkit:CalendarExtender ID="TextBox1_CalendarExtender" runat="server" BehaviorID="TextBox1_CalendarExtender" TargetControlID="TextBox1" />
                     <br />
                     <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
                     <br />
   
    </div>
            </ContentTemplate>
        </asp:UpdatePanel>

     
    </form>
</body>
</html>


No comments:

Post a Comment