Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q1 2012 released 04/11/2012
select

Input / Validation through a web service

Add new recordRefresh
 OrderIDProductQuantityDiscountUnitsInStock 
Page size:
select
 2155 items in 216 pages
10248Queso Cabrales 12 022
10248Singaporean Hokkien Fried Mee 10 026
10248Mozzarella di Giovanni 5 014
10249Tofu 9 035
10249Manjimup Dried Apples 40 020
10250Jack's New England Clam Chowder 10 085
10250Manjimup Dried Apples 35 0.1520
10250Louisiana Fiery Hot Pepper Sauce 15 0.1576
10251Gustaf's Knäckebröd 6 0.05104
10251Ravioli Angelo 15 0.0536

  • The following example demonstrates RadInputManager's validation through a web service. Detailed order information can be added or changed only if the specified quantity is not greater than the units in stock of the corresponding product.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="C#" AutoEventWireup="true" CodeFile="defaultcs.aspx.cs" Inherits="Input_Examples_RadInputManager_DynamicInputFilterSettings_DefaultCS" %>

    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server"></qsf:HeadTag>
        <style type="text/css">
            .invalid
            {
                color: red !important;
            }
        </style>
    </head>
    <body class="BODY">
        <form id="mainForm" method="post" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="C#"></qsf:Header>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        <telerik:AjaxUpdatedControl ControlID="RadInputManager1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
        <!-- content start -->
        <div>
            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                <script type="text/javascript">

                    function onValidating(sender, args) {

                        var context = {};
                        context["ProductID"] = $find($($get(sender.get_targetControlIDs()[0])).parents("tr:first").prev("tr").find("div[id$='RCB_ProductID']:first").attr("ID")).get_selectedItem().get_value();
                        args.set_context(context);

                    }

                    function pageLoad() {
                        window.$ = jQuery = $telerik.$;
                    }
            
                
                </script>
            </telerik:RadScriptBlock>
            <telerik:RadInputManager ID="RadInputManager1" OnValidating="RadInputManager1_Validating"
                runat="server">
                <telerik:NumericTextBoxSetting BehaviorID="TextBoxBehavior1" Type="Number" DecimalDigits="0" InvalidStyleDuration="2000">
                    <Validation Location="validationservice/InputManagerValidationService.asmx" ValidateOnEvent="Submit"
                        Method="ValidateQuantity" />
                    <ClientEvents OnValidating="onValidating" />
                </telerik:NumericTextBoxSetting>
            </telerik:RadInputManager>
            <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AllowMultiRowEdit="true"
                GridLines="None" AllowPaging="True" OnInsertCommand="RadGrid1_InsertCommand"
                OnUpdateCommand="RadGrid1_UpdateCommand" OnItemCreated="RadGrid1_ItemCreated"
                AllowAutomaticUpdates="true" AllowAutomaticInserts="true" AllowAutomaticDeletes="true"
                AllowSorting="true">
                <MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID, ProductID" DataSourceID="SqlDataSource1"
                    CommandItemDisplay="Top">
                    <PagerStyle Mode="NextPrevAndNumeric" />
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" />
                        <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" HeaderText="OrderID"
                            SortExpression="OrderID" UniqueName="OrderID">
                        </telerik:GridBoundColumn>
                        <telerik:GridDropDownColumn DataField="ProductID" DataSourceID="SqlDataSource2" UniqueName="ProductID"
                            HeaderText="Product" ListTextField="ProductName" ListValueField="ProductID">
                        </telerik:GridDropDownColumn>
                        <telerik:GridTemplateColumn DataField="Quantity" UniqueName="Quantity" HeaderText="Quantity"
                            SortExpression="Quantity">
                            <ItemTemplate>
                                <asp:Label ID="quantityLabel" runat="server" Text='<%#Eval("Quantity") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="quantityNumBox" runat="server" Text='<%#Bind("Quantity") %>'>
                                </asp:TextBox>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="Discount" HeaderText="Discount" SortExpression="Discount"
                            UniqueName="Discount">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="UnitsInStock" DataType="System.Int32" HeaderText="UnitsInStock"
                            ReadOnly="true" SortExpression="UnitsInStock" UniqueName="UnitsInStock">
                        </telerik:GridBoundColumn>
                        <telerik:GridButtonColumn CommandName="Delete" ButtonType="ImageButton" />
                    </Columns>
                    <EditFormSettings>
                        <EditColumn ButtonType="ImageButton" />
                    </EditFormSettings>
                </MasterTableView>
                <ValidationSettings EnableValidation="false" />
            </telerik:RadGrid>
            <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                runat="server" SelectCommand="SELECT OrderID, Products.ProductID, ProductName, Quantity, Discount, UnitsInStock From [Order Details] join Products on [Order Details].ProductID = Products.ProductID"
                ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [Order Details] WHERE [OrderID] = @original_OrderID AND [ProductID] = @original_ProductID"
                InsertCommand="INSERT INTO [Order Details] ([OrderID], [ProductID], [Quantity], [Discount]) VALUES (@OrderID, @ProductID, @Quantity, @Discount)"
                OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [Order Details] SET [ProductID]=@ProductID, [Quantity] = @Quantity, [Discount] = @Discount WHERE [OrderID] = @original_OrderID AND [ProductID] = @original_ProductID AND [Quantity] = @original_Quantity AND [Discount] = @original_Discount">
                <DeleteParameters>
                    <asp:Parameter Name="original_OrderID" Type="Int32" />
                    <asp:Parameter Name="original_ProductID" Type="Int32" />
                    <asp:Parameter Name="original_Quantity" Type="Int16" />
                    <asp:Parameter Name="original_Discount" Type="Single" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Quantity" Type="Int16" />
                    <asp:Parameter Name="Discount" Type="Single" />
                    <asp:Parameter Name="original_OrderID" Type="Int32" />
                    <asp:Parameter Name="original_ProductID" Type="Int32" />
                    <asp:Parameter Name="original_Quantity" Type="Int16" />
                    <asp:Parameter Name="original_Discount" Type="Single" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="OrderID" Type="Int32" />
                    <asp:Parameter Name="ProductID" Type="Int32" />
                    <asp:Parameter Name="Quantity" Type="Int16" />
                    <asp:Parameter Name="Discount" Type="Single" />
                </InsertParameters>
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                runat="server" SelectCommand="SELECT ProductID, ProductName from Products ">
            </asp:SqlDataSource>
        </div>
        <!-- content end -->
        <qsf:Footer ID="Footer1" runat="server"></qsf:Footer>
        </form>
    </body>
    </html>

Get more than expected!

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2012 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451