This is a migrated thread and some comments may be shown as answers.

2 controls with Autopostbacks

6 Answers 103 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Pavel Brokhman
Top achievements
Rank 1
Pavel Brokhman asked on 16 Dec 2009, 07:45 PM
1. We have RadGrid Control.
2. Each row has EditTemplate.
3. There we have TabControl with 2 tabs
4. 1st tab contains TextBox, Label and Button

I am going below to simplify the requirements:
1. When we click on the button we call Popup Window. (ButtonClick with Postback)
2. When we change some value in TextBox, we put for instant Success or Failed messages in Label (TextChanged with Postback).

Here is scenario I am trying to achieve:
1. Change the value in TextBox
2. Click on the button or on second tab
3. Results - some message in Label + (window is Pop-upped or 2nd tab is opened)

What happens is:
We have to click twice on button to get the result.

Is there any other way, except PostBacks to solve it using RadControls?

6 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 19 Dec 2009, 09:07 AM
Hello Pavel,

Could you please send us a sample project, or at least your code, illustrating your scenario and the described problem?

Greetings,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Pavel Brokhman
Top achievements
Rank 1
answered on 30 Dec 2009, 07:38 PM
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucFinanceReq.ascx.cs" 
    Inherits="AltusEmpPortals.UserControls.ucFinanceReq" EnableViewState="true" %>  
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>  
<telerik:RadAjaxPanel ID="radAjaxPanel1" runat="server" LoadingPanelID="radAjaxLoadingPanel1">  
    <div id="divRequest" runat="server">  
        <table cellpadding="0" cellspacing="0" border="0" width="100%">  
            <!-- Page Title -->  
            <tr>  
            </tr>  
            <!-- Response Msg: Shows response messages to user's actions -->  
            <tr style="height: 20px">  
            </tr>  
            <!-- Tabs -->  
            <tr>  
                <td>  
                </td>  
                <td align="right">  
                </td>  
                <td style="width: 20px">  
                </td>  
            </tr>  
            <tr>  
                <td colspan="3">  
                    <div style="padding: 0px 20px 0px 0px">  
                        <telerik:RadMultiPage ID="radMultiPage" runat="server" Width="100%" SelectedIndex="0" 
                            CssClass="multiPage">  
                            <telerik:RadPageView ID="radPVDetail" runat="server">  
                                <div style="padding: 15px 10px 10px 10px">  
                                    <table cellpadding="0" cellspacing="0" border="0" width="100%">  
                                        <tr>  
                                            <td colspan="3">  
                                                <fieldset id="fsEntries" title="Entries" style="width: 100%">  
                                                    <telerik:RadGrid ID="grdEntries" runat="server" AutoGenerateColumns="False" AllowSorting="True" 
                                                        AllowPaging="True" Skin="Vista" PageSize="10" GridLines="None" EmptyDataText="No Entry has been added." 
                                                        ShowHeader="true" AllowMultiRowEdit="false" ValidationSettings-ValidationGroup="valGrpEntry">  
                                                        <MasterTableView EditMode="InPlace" DataKeyNames="LineID, DocType, ReqNo" AllowMultiColumnSorting="false" 
                                                            AllowSorting="true" CurrentResetPageIndexAction="SetPageIndexToFirst">  
                                                            <AlternatingItemStyle CssClass="txtSmall" BackColor="AliceBlue" />  
                                                            <ItemStyle CssClass="txtSmall" />  
                                                            <EditItemStyle BackColor="#94CFEF" />  
                                                            <HeaderStyle Font-Size="8pt" />  
                                                            <Columns>  
                                                                <telerik:GridTemplateColumn UniqueName="Edit1" EditFormColumnIndex="0" ItemStyle-VerticalAlign="Top" 
                                                                    ItemStyle-Width="0" ItemStyle-HorizontalAlign="Center">  
                                                                    <ItemTemplate>  
                                                                        <b><%# ((System.Data.DataRowView)Container.DataItem)["RowNumber"] %>.</b><br /><asp:Image ID="imgEntryWarning" runat="server" Visible="false" ImageUrl="Images/warning.png" />  
                                                                    </ItemTemplate>  
                                                                    <EditItemTemplate>  
                                                                        <b><%# ((System.Data.DataRowView)Container.DataItem)["RowNumber"] %>.</b><br />  
                                                                    </EditItemTemplate>  
                                                                </telerik:GridTemplateColumn>  
                                                                <telerik:GridTemplateColumn HeaderText="Entry Details" EditFormColumnIndex="1">  
                                                                    <ItemTemplate>  
                                                                        <asp:Label runat="server" ID="lblMessage" ForeColor="Red" Visible="false" Font-Bold="true" />  
                                                                        <table cellpadding="0" cellspacing="0" width="100%" border="0">  
                                                                            <tr>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:3px; width:5%;" nowrap>  
                                                                                    <%# GetEntryTypeName((string)((System.Data.DataRowView)Container.DataItem)["iTypeID"]) %>
                                                                                    #:  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px; width:18%;">  
                                                                                    <%# ((System.Data.DataRowView)Container.DataItem)["ItemID"] %>  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:3px; width:5%;">  
                                                                                    Description:  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px; width:25%;">  
                                                                                    <%# ((System.Data.DataRowView)Container.DataItem)["Desc"]%>  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:3px; width:5%;">Quantity:</td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px; width:20%;">  
                                                                                    <%# String.Format("{0:n}",((System.Data.DataRowView)Container.DataItem)["Quantity"])%>&nbsp;<%# ((System.Data.DataRowView)Container.DataItem)["UnitOfMeasure"]%>  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style: none; padding:3px; width: 5%;" nowrap>  
                                                                                    Unit Cost:  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px; width:10%;">  
                                                                                    <%# String.Format("${0:n}", ((System.Data.DataRowView)Container.DataItem)["UnitCost"])%>  
                                                                                </td>  
                                                                            </tr>  
                                                                            <tr>  
                                                                                <td class="labelCell_AlignTop" style="border-style: none; padding:3px;" nowrap>  
                                                                                    Account#:  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style: none; padding:3px;">  
                                                                                    <%# ((System.Data.DataRowView)Container.DataItem)["G_LAccountNo"] %>  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style: none; padding:3px;" nowrap>  
                                                                                    Comb. Code:  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style: none; padding:3px;">  
                                                                                    <%# ((System.Data.DataRowView)Container.DataItem)["CombinationCode"] %>  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style: none; padding:3px;" nowrap>  
                                                                                    Ext. Cost:  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px;">  
                                                                                    <asp:Label ID="lblExtCost" runat="server" CssClass="txtSmall"></asp:Label>  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" colspan="2" style="border-style: none; padding:3px;" nowrap>  
                                                                                    <asp:CheckBox ID="chkReview" AutoPostBack="true" runat="server" Text="Fixed Asset Review" 
                                                                                        Checked='<%#((System.Data.DataRowView)Container.DataItem)["FixedAssetReview"] %>'  
                                                                                        CausesValidation="false" OnCheckedChanged="chkReview_CheckedChanged" />  
                                                                                </td>  
                                                                            </tr>  
                                                                            <tr>  
                                                                                <td class="labelCell_AlignTop" style="border-style: none; padding:3px;" nowrap>  
                                                                                    Purchaser Code:  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style: none; padding:3px;">  
                                                                                    <%# ((System.Data.DataRowView)Container.DataItem)["Purchase_Code"]%>  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style: none; padding:3px;" nowrap>  
                                                                                    Vendor Item#:  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style: none; padding:3px;">  
                                                                                    <%# ((System.Data.DataRowView)Container.DataItem)["VendItemNo"]%>  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style: none; padding:3px;">  
                                                                                    Vendor:  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style: none; padding:3px;">  
                                                                                    <%# ((System.Data.DataRowView)Container.DataItem)["Vendor"]%>  
                                                                                </td>  
                                                                            </tr>  
                                                                            <div id="divTaxInfo" runat="server">  
                                                                                <tr>  
                                                                                    <td class="labelCell_AlignTop" style="border-style: none; padding:3px;" nowrap>  
                                                                                        <asp:Label ID="lblTaxAreaTitle" runat="server" Text="Tax Area:"></asp:Label>  
                                                                                    </td>  
                                                                                    <td class="td_AlignTop" style="border-style: none; padding:3px;">  
                                                                                        <asp:Label ID="lblTaxArea" runat="server" Text='<%# ((System.Data.DataRowView)Container.DataItem)["TaxAreaDesc"]%>'></asp:Label>  
                                                                                    </td>  
                                                                                    <td class="td_AlignTop" colspan="3" style="border-style: none; padding:3px;">  
                                                                                        <asp:Label ID="lblTaxes" runat="server"></asp:Label>  
                                                                                    </td>  
                                                                                </tr>  
                                                                            </div>  
                                                                            <div id="divLocation" runat="server" visible='<%# ((System.Data.DataRowView)Container.DataItem)["EnableLocToLoc"].ToString().Trim() == "1" %>'>  
                                                                                <tr>  
                                                                                    <td class="labelCell_AlignTop" style="border-style: none;" nowrap>  
                                                                                        From Loc.:  
                                                                                    </td>  
                                                                                    <td class="td_AlignTop" style="border-style: none; padding:3px;" colspan="3">  
                                                                                        <asp:Label ID="lblFrom" runat="server" CssClass="txtSmall" Text='<%# ((System.Data.DataRowView)Container.DataItem)["FromLoc"]%>'  
                                                                                            Visible='<%# ((System.Data.DataRowView)Container.DataItem)["EnableLocToLoc"].ToString().Trim() == "1" %>'></asp:Label>  
                                                                                    </td>  
                                                                                    <td class="labelCell_AlignTop" style="border-style: none; padding:3px;" nowrap>  
                                                                                        To Loc.:  
                                                                                    </td>  
                                                                                    <td class="td_AlignTop" style="border-style: none; padding:3px;" colspan="3">  
                                                                                        <asp:Label ID="lblTo" runat="server" CssClass="txtSmall" Text='<%# ((System.Data.DataRowView)Container.DataItem)["ToLoc"]%>'  
                                                                                            Visible='<%# ((System.Data.DataRowView)Container.DataItem)["EnableLocToLoc"].ToString().Trim() == "1" %>'></asp:Label>  
                                                                                    </td>  
                                                                                </tr>  
                                                                            </div>  
                                                                            <div id="divComments" runat="server" visible="false">  
                                                                                <tr style="padding: 1px;">  
                                                                                    <td class="labelCell_AlignTop" style="border-style: none;" nowrap>  
                                                                                        Details:  
                                                                                    </td>  
                                                                                    <td class="td_AlignTop" style="border-style: none;" colspan="7">  
                                                                                        <%# ((System.Data.DataRowView)Container.DataItem)["Comments"]%>  
                                                                                    </td>  
                                                                                </tr>  
                                                                            </div>  
                                                                            <tr>  
                                                                                <td class="td_AlignTop" style="border-style: none; padding: 0px;" colspan="8">  
                                                                                    <fieldset>  
                                                                                        <legend>Categorization</legend>  
                                                                                        <asp:Label ID="lblDims" runat="server"></asp:Label>  
                                                                                    </fieldset>  
                                                                                </td>  
                                                                            </tr>  
                                                                        </table>  
                                                                    </ItemTemplate>  
                                                                    <EditItemTemplate>  
                                                                         <table cellpadding="0" cellspacing="0" width="100%" style="padding:0px; margin:0px" border="0">  
                                                                            <tr style="padding: 1px;">  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:0px; width:10%" nowrap>  
                                                                                    <asp:Label ID="LabeliTypeID" runat="server" Text='<%# GetEntryTypeName((string)((System.Data.DataRowView)Container.DataItem)["iTypeID"]) %>' />
                                                                                    #:&nbsp;&nbsp;               
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:0px; width:14%" nowrap>  
                                                                                    <asp:TextBox Enabled="true" ID="itemID" MaxLength="20" runat="server" Width="90px" Text='<%# ((System.Data.DataRowView)Container.DataItem)["ItemID"] %>' AutoPostBack="true" OnTextChanged="itemID_TextChanged" CausesValidation="true" ValidationGroup="valGrpItemID" />  
                                                                                    <asp:ImageButton ID="imbChange" runat="server" ImageUrl="./Images/Search.gif" CommandName="Change" 
                                                                                        ToolTip="Change Description" />&nbsp;&nbsp;  
                                                                                        <asp:CustomValidator ID="custValItemID" ControlToValidate="itemID" Display="Dynamic" 
                                                                                            class="txtNormal" runat="server" ValidateEmptyText="true" OnServerValidate="custValItemID_ServerValidate" 
                                                                                            ValidationGroup="valGrpItemID" Text="<br/>Invalid Expense Type/Item No." />  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:0px; width:5%">  
                                                                                    Desc.:&nbsp;&nbsp;  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:0px; width:25%">  
                                                                                    <%# ((System.Data.DataRowView)Container.DataItem)["Desc"] %>  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:0px; width:5%" align="left">  
                                                                                    Quantity:&nbsp;&nbsp;  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:0px; width:25%;" align="left" nowrap>                                                       
                                                                                    <asp:TextBox ID="txtQuantity" runat="server" Width="40px" MaxLength="15" Text='<%# String.Format("{0:n}",((System.Data.DataRowView)Container.DataItem)["Quantity"])%>'  
                                                                                        CssClass="txtSmall"></asp:TextBox>  
                                                                                    <asp:DropDownList ID="ddlUnitMeasure" CssClass="txtSmall" runat="server" Width="60px" />&nbsp;&nbsp;  
                                                                                    <asp:CompareValidator ID="compQuantity" runat="server" ValidationGroup="valGrpEntry" 
                                                                                        EnableClientScript="true" Display="Dynamic" ControlToValidate="txtQuantity" Text="<br>* Quantity must be at least 1." 
                                                                                        ErrorMessage="* Quantity must be at least 1." ValueToCompare="1" Operator="GreaterThanEqual"></asp:CompareValidator>  
                                                                                    <asp:RegularExpressionValidator ID="reValQuantity" runat="server" EnableClientScript="true" 
                                                                                        Display="Dynamic" ValidationGroup="valGrpEntry" ControlToValidate="txtQuantity" 
                                                                                        Text="<br>* Quantity must be numeric; e.g. 8, 3.5." ErrorMessage="* Quantity must be numeric; e.g. 8, 3.5" 
                                                                                        ValidationExpression="^(-)?[0-9]+(\.[0-9]+)?$"></asp:RegularExpressionValidator>  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:0px; width:6%;" align="left" nowrap>  
                                                                                    Unit Cost:&nbsp;&nbsp;  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:0px;" width="10%" align="left">  
                                                                                    <asp:TextBox ID="txtUnitCost" runat="server" Width="45px" MaxLength="20" onchange="FlagGridChange();" 
                                                                                        Text='<%# String.Format("{0:n}",((System.Data.DataRowView)Container.DataItem)["UnitCost"])%>'  
                                                                                        CssClass="txtSmall"></asp:TextBox>  
                                                                                    <asp:RegularExpressionValidator ID="reValUnitCost" runat="server" EnableClientScript="false" 
                                                                                        ValidationGroup="valGrpEntry" ControlToValidate="txtUnitCost" ErrorMessage="&nbsp;Unit cost must be a positive numeric, e.g. 8, 3.5" 
                                                                                        ValidationExpression="^[0-9]+(\.[0-9]+)?$"></asp:RegularExpressionValidator>  
                                                                                </td>                                                         
                                                                            </tr>  
                                                                            <tr style="padding: 3px;">  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding-left:0;" nowrap>  
                                                                                    Account#:&nbsp;&nbsp;            
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding-left:0;" nowrap>  
                                                                                    <asp:TextBox ID="tb_glAccountNo" Width="90px" MaxLength="20" runat="server" Text='<%# ((System.Data.DataRowView)Container.DataItem)["G_LAccountNo"] %>' CausesValidation="true" AutoPostBack="true" ValidationGroup="valGrpAccountNo" OnTextChanged="AccountNo_TextChanged" Enabled='<%# ((System.Data.DataRowView)Container.DataItem)["Type"].ToString().Equals("0") ? false : true %>' />  
                                                                                    <asp:ImageButton ID="imbChangeGLAct" runat="server" ImageUrl="./Images/Search.gif" 
                                                                                        CommandName="ChangeGLAccount" ToolTip="Change GL Account No" Visible='<%# ((System.Data.DataRowView)Container.DataItem)["Type"].ToString().Equals("0") ? false : true %>' />  
                                                                                    <asp:CustomValidator ID="CustValAccountNo" ControlToValidate="tb_glAccountNo" Display="Dynamic" 
                                                                                        class="txtNormal" runat="server" OnServerValidate="CustValAccountNo_ServerValidate" 
                                                                                        ValidationGroup="valGrpAccountNo" Text="<br/>Invalid Account No." />  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding-left:0;" nowrap>  
                                                                                    <asp:Label ID="lblCombinationCodehead2" runat="server" CssClass="txtSmall" Text="Comb. Code:"></asp:Label>                                                                                                            
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding-left:0;" nowrap>  
                                                                                    <asp:TextBox ID="lblCombinationCode2" MaxLength="20" CssClass="txtSmall" Width="100px" runat="server" Text='<%# ((System.Data.DataRowView)Container.DataItem)["CombinationCode"] %>' CausesValidation="true" AutoPostBack="true" ValidationGroup="valGrpCombinationCode" OnTextChanged="CombinationCode_TextChanged" />  
                                                                                    <asp:ImageButton ID="imbChangeCombination2" runat="server" ImageUrl="./Images/Search.gif" CommandName="ChangeCombination" 
                                                                                        ToolTip="Change Combination Code" />  
                                                                                    <asp:CustomValidator ID="CustValCombinationCode2" ControlToValidate="lblCombinationCode2" 
                                                                                        Display="Dynamic" class="txtNormal" runat="server" OnServerValidate="CustValCombinationCode_ServerValidate" 
                                                                                        ValidationGroup="valGrpCombinationCode" Text="<br/>Invalid Combination Code" />  
                                                                                    <asp:HiddenField ID="hdnCombinationChanged" Value="false" runat="server" />  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style: none; padding-left:0;" nowrap>  
                                                                                    Ext. Cost:&nbsp;&nbsp;  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none;" nowrap>  
                                                                                     <asp:Label ID="lblExtCost" runat="server" CssClass="txtSmall"></asp:Label>  
                                                                                </td>   
                                                                                <td class="labelCell_AlignTop" style="border-style: none; padding-left:0;" align="left" colspan="2" nowrap>  
                                                                                    <asp:CheckBox ID="chkReview" AutoPostBack="true" runat="server" Text="Fixed Asset Review" 
                                                                                        Checked='<%#((System.Data.DataRowView)Container.DataItem)["FixedAssetReview"] %>'  
                                                                                        CausesValidation="false" OnCheckedChanged="chkReview_CheckedChanged" />  
                                                                                </td>   
                                                                            </tr>  
                                                                            <tr style="padding: 3px;" align="left">  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:0px;" nowrap>  
                                                                                    Purchaser Code: &nbsp;&nbsp;  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:0px;" nowrap>  
                                                                                    <asp:DropDownList ID="ddlPurchaseCode" runat="server" Visible="true" CssClass="txtSmall"></asp:DropDownList>                                                                              
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:0px;" nowrap>  
                                                                                    Vendor Item#: &nbsp;  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:0px;">  
                                                                                    <asp:TextBox ID="txtVendItemNo" runat="server" Width="100px" MaxLength="20" Text='<%# ((System.Data.DataRowView)Container.DataItem)["VendItemNo"]%>'  
                                                                                        Visible='<%# ((System.Data.DataRowView)Container.DataItem)["Type"].ToString().Equals("1") %>'  
                                                                                        CssClass="txtSmall"></asp:TextBox>  
                                                                                    <asp:RequiredFieldValidator Enabled='<%# Eval("IsRequireVendItemNo").ToString().Equals("1") %>'  
                                                                                        ID="reqTxtVendItemNo" ControlToValidate="txtVendItemNo" runat="server" Text="* Required." 
                                                                                        ErrorMessage="* Vendor Item No is required." Display="Dynamic" ValidationGroup="valGrpEntry"></asp:RequiredFieldValidator>                                                                                                      
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:0px;">  
                                                                                    Vendor:  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:0px;" colspan="3">  
                                                                                    <asp:DropDownList ID="ddlReqVendors" Width="90%" runat="server" CssClass="txtSmall"></asp:DropDownList>  
                                                                                </td>                                                                                                                                                                                                                                       
                                                                            </tr>  
                                                                            <tr style="padding-top: 0px;" align="left">                                                                                                                       
                                                                                <div id="divTaxInfo" runat="server">  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding-left:0px; padding-top:3px;" nowrap>  
                                                                                    Tax Area:&nbsp;&nbsp;  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding-top:4px; padding-left:0px;" align="left">  
                                                                                    <asp:DropDownList ID="ddlTaxArea" runat="server" DataTextField="Desc" DataValueField="Code" 
                                                                                        DataSourceID="sqlSrcTaxArea" CssClass="txtSmall">  
                                                                                    </asp:DropDownList>  
                                                                                </td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding-top:4px; padding-left:0px; padding-bottom:0px;" colspan="2" align="left" nowrap>  
                                                                                    <table cellpadding="0" cellspacing="0" border="0" width="100%">  
                                                                                        <tr>  
                                                                                            <td class="labelCell_AlignTop" style="border-style:none; padding:0px; padding-top:2px;" nowrap>                                                                           
                                                                                                <asp:Label ID="lblGST" runat="server" CssClass="txtNormalBold" Text="GST:"></asp:Label>&nbsp;&nbsp;  
                                                                                            </td>  
                                                                                            <td class="td_AlignTop" style="border-style:none; padding:0px; padding-top:2px;">  
                                                                                                <asp:TextBox ID="txtGST" MaxLength="15" Width="50px" runat="server"></asp:TextBox>  
                                                                                            </td>  
                                                                                            <td class="td_AlignTop" style="border-style:none; padding:0px;">  
                                                                                                <asp:Label ID="lblTaxes" runat="server"></asp:Label>  
                                                                                            </td>  
                                                                                        </tr>  
                                                                                    </table>      
                                                                                </td>  
                                                                                </div>                                                                               
                                                                            </tr>  
                                                                            <tr style="padding: 0px;">  
                                                                                <div id="divLocation" runat="server" visible='<%# ((System.Data.DataRowView)Container.DataItem)["EnableLocToLoc"].ToString().Trim() == "1" %>'>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:0px;" nowrap>From Loc.:</td>  
                                                                                <td class="td_AlignTop" style="border-style:none; padding-left:0px; padding-top:0px" colspan="3">  
                                                                                    <asp:DropDownList ID="ddlFromLoc" runat="server" AutoPostBack="true" 
                                                                                        DataTextField="Name" DataValueField="Code" DataSourceID="sqlSrcLocation" CssClass="txtSmall" 
                                                                                        Visible='<%# ((System.Data.DataRowView)Container.DataItem)["EnableLocToLoc"].ToString().Trim() == "1" %>'  
                                                                                        OnSelectedIndexChanged="ddlLocationFrom_SelectedIndexChanged">  
                                                                                    </asp:DropDownList>  
                                                                                </td>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:0px;" nowrap>To Loc.:</td>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:0px;" colspan="3" nowrap>  
                                                                                    <asp:DropDownList ID="ddlToLoc" runat="server" AutoPostBack="true" DataTextField="Name" 
                                                                                        DataValueField="Code" DataSourceID="sqlSrcLocation" CssClass="txtSmall" Visible='<%# ((System.Data.DataRowView)Container.DataItem)["EnableLocToLoc"].ToString().Trim() == "1" %>'  
                                                                                        OnSelectedIndexChanged="ddlLocationTo_SelectedIndexChanged">  
                                                                                    </asp:DropDownList>  
                                                                                </td>     
                                                                                </div>                                                                            
                                                                            </tr>     
                                                                            <tr style="padding: 1px;">  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:0px;" nowrap>Details:</td>  
                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:0px;" colspan="7">  
                                                                                    <asp:TextBox ID="txtComments" runat="server" MaxLength="250" CssClass="txtSmall" 
                                                                                        Text='<%# ((System.Data.DataRowView)Container.DataItem)["Comments"] %>' TextMode="MultiLine" 
                                                                                        Rows="2" Width="95%" onkeydown="return LimitInput(this, 250, true);" onpaste="return LimitPaste(this, 250, true);"></asp:TextBox>       
                                                                                </td>   
                                                                            </tr>                                                                     
                                                                            <tr style="padding: 1px;">  
                                                                                <td class="td_AlignTop" style="border-style:none; padding:0px;" colspan="8" nowrap>  
                                                                                    <fieldset>   
                                                                                        <legend>Categorization</legend>  
                                                                                        <table cellpadding="0" cellspacing="0" border="0">    
                                                                                        <div id="div1" runat="server">  
                                                                                            <tr>  
                                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <asp:Label ID="lblDimLabel1" runat="server" CssClass="txtSmall"></asp:Label>  
                                                                                                </td>  
                                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <telerik:RadComboBox ID="ddlDim1" runat="server" Height="200px" Width="200px" Filter="Contains" MarkFirstMatch="true" ChangeTextOnKeyBoardNavigation="false" Visible="false" 
                                                                                                         OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true"></telerik:RadComboBox>  
 
                                                                                                    <%--<asp:DropDownList ID="ddlDim1" runat="server" CssClass="txtSmall" Visible="false" 
                                                                                                         OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true">  
                                                                                                    </asp:DropDownList>--%>  
                                                                                                </td>  
                                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <asp:Label ID="lblDimLabel2" runat="server" CssClass="txtSmall"></asp:Label>  
                                                                                                </td>  
                                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <telerik:RadComboBox ID="ddlDim2" runat="server" Height="200px" Width="200px" Filter="Contains" MarkFirstMatch="true" ChangeTextOnKeyBoardNavigation="false" CssClass="txtSmall" Visible="false" 
                                                                                                         OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true"></telerik:RadComboBox>  
                                                                                                    <%--<asp:DropDownList ID="ddlDim2" runat="server" CssClass="txtSmall" Visible="false" 
                                                                                                        OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true">  
                                                                                                    </asp:DropDownList>--%>  
                                                                                                </td>  
                                                                                             </tr>  
                                                                                        </div>  
                                                                                        <div id="div2" runat="server">  
                                                                                             <tr>  
                                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <asp:Label ID="lblDimLabel3" runat="server" CssClass="txtSmall"></asp:Label>  
                                                                                                </td>  
                                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <telerik:RadComboBox ID="ddlDim3" runat="server" Height="200px" Width="200px" Filter="Contains" MarkFirstMatch="true" ChangeTextOnKeyBoardNavigation="false" CssClass="txtSmall" Visible="false" 
                                                                                                         OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true"></telerik:RadComboBox>  
                                                                                                    <%--<asp:DropDownList ID="ddlDim3" runat="server" CssClass="txtSmall" Visible="false" 
                                                                                                        OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true">  
                                                                                                    </asp:DropDownList>--%>  
                                                                                                </td>  
                                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <asp:Label ID="lblDimLabel4" runat="server" CssClass="txtSmall"></asp:Label>  
                                                                                                </td>  
                                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <telerik:RadComboBox ID="ddlDim4" runat="server" Height="200px" Width="200px" Filter="Contains" MarkFirstMatch="true" ChangeTextOnKeyBoardNavigation="false" CssClass="txtSmall" Visible="false" 
                                                                                                         OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true"></telerik:RadComboBox>  
                                                                                                    <%--<asp:DropDownList ID="ddlDim4" runat="server" CssClass="txtSmall" Visible="false" 
                                                                                                        OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true">  
                                                                                                    </asp:DropDownList>--%>  
                                                                                                </td>  
                                                                                             </tr>  
                                                                                        </div>  
                                                                                        <div id="div3" runat="server">  
                                                                                            <tr>  
                                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <asp:Label ID="lblDimLabel5" runat="server" CssClass="txtSmall"></asp:Label>  
                                                                                                </td>  
                                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <telerik:RadComboBox ID="ddlDim5" runat="server" Height="200px" Width="200px" Filter="Contains" MarkFirstMatch="true" ChangeTextOnKeyBoardNavigation="false" CssClass="txtSmall" Visible="false" 
                                                                                                         OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true"></telerik:RadComboBox>  
                                                                                                    <%--<asp:DropDownList ID="ddlDim5" runat="server" CssClass="txtSmall" Visible="false" 
                                                                                                        OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true">  
                                                                                                    </asp:DropDownList>--%>  
                                                                                                </td>  
                                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <asp:Label ID="lblDimLabel6" runat="server" CssClass="txtSmall"></asp:Label>  
                                                                                                </td>  
                                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <telerik:RadComboBox ID="ddlDim6" runat="server" Height="200px" Width="200px" Filter="Contains" MarkFirstMatch="true" ChangeTextOnKeyBoardNavigation="false" CssClass="txtSmall" Visible="false" 
                                                                                                         OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true"></telerik:RadComboBox>  
                                                                                                    <%--<asp:DropDownList ID="ddlDim6" runat="server" CssClass="txtSmall" Visible="false" 
                                                                                                        OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true">  
                                                                                                    </asp:DropDownList>--%>  
                                                                                                </td>  
                                                                                            </tr>  
                                                                                            </div>  
                                                                                        <div id="div4" runat="server">    
                                                                                            <tr>                                                                                       
                                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <asp:Label ID="lblDimLabel7" runat="server" CssClass="txtSmall"></asp:Label>  
                                                                                                </td>  
                                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <telerik:RadComboBox ID="ddlDim7" runat="server" Height="200px" Width="200px" Filter="Contains" MarkFirstMatch="true" ChangeTextOnKeyBoardNavigation="false" CssClass="txtSmall" Visible="false" 
                                                                                                         OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true"></telerik:RadComboBox>  
                                                                                                    <%--<asp:DropDownList ID="ddlDim7" runat="server" CssClass="txtSmall" Visible="false" 
                                                                                                        OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true">  
                                                                                                    </asp:DropDownList>--%>  
                                                                                                </td>  
                                                                                                <td class="labelCell_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <asp:Label ID="lblDimLabel8" runat="server" CssClass="txtSmall"></asp:Label>  
                                                                                                </td>  
                                                                                                <td class="td_AlignTop" style="border-style:none; padding:3px;">  
                                                                                                    <telerik:RadComboBox ID="ddlDim8" runat="server" Height="200px" Width="200px" Filter="Contains" MarkFirstMatch="true" ChangeTextOnKeyBoardNavigation="false" CssClass="txtSmall" Visible="false" 
                                                                                                         OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true"></telerik:RadComboBox>  
                                                                                                    <%--<asp:DropDownList ID="ddlDim8" runat="server" CssClass="txtSmall" Visible="false" 
                                                                                                        OnInit="ddlDim_Init" OnSelectedIndexChanged="ddlDim_SelectedIndexChanged" AutoPostBack="true">  
                                                                                                    </asp:DropDownList>--%>  
                                                                                                </td>                                                                                                 
                                                                                            </tr>  
                                                                                            </div>                                                                                        
                                                                                        </table>                                                                                      
                                                                                        <asp:DropDownList ID="ddlCombinationcode" CssClass="txtSmall" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddlCombinationCodeChanged" Visible="false" />  
                                                                                        <asp:TextBox Visible="false" Enabled="false" ID="lblCombinationCode1" CssClass="txtSmall" runat="server" 
                                                                                            Text='<%# ((System.Data.DataRowView)Container.DataItem)["CombinationCode"] %>' CausesValidation="true" AutoPostBack="true" ValidationGroup="valGrpCombinationCode" OnTextChanged="CombinationCode_TextChanged" />  
                                                                                    </fieldset>  
                                                                                </td>  
                                                                            </tr>                                                                        
                                                                        </table>                                                                                                                           
                                                                    </EditItemTemplate>  
                                                                </telerik:GridTemplateColumn>  
                                                                <telerik:GridTemplateColumn Visible="false" HeaderText="Rec'd" UniqueName="ReceivedBy" 
                                                                    ItemStyle-Width="0%" DataField="ReceivedBy" SortExpression="ReceivedBy" ItemStyle-VerticalAlign="Top">  
                                                                    <ItemTemplate>  
                                                                        <asp:Label ID="lblReceivedBy" runat="server" CssClass="labelCell"></asp:Label>  
                                                                        <asp:LinkButton ID="lbtnMarkReceived" runat="server" CausesValidation="false" CommandName="MarkReceived" 
                                                                            Text="Mark As Rec'd"></asp:LinkButton><br />  
                                                                        <asp:LinkButton ID="lbtnClearReceived" runat="server" CausesValidation="false" CommandName="ClearReceived" 
                                                                            Text="Clear"></asp:LinkButton>  
                                                                        <br />  
                                                                        <br />  
                                                                        <br />  
                                                                        <br />  
                                                                        <br />  
                                                                    </ItemTemplate>  
                                                                </telerik:GridTemplateColumn>  
                                                                <telerik:GridTemplateColumn UniqueName="Edit" EditFormColumnIndex="0" ItemStyle-VerticalAlign="Top" 
                                                                    ItemStyle-Width="1%" ItemStyle-HorizontalAlign="Center" >  
                                                                    <ItemTemplate>  
                                                                        <div id="divEditButtons" runat="server">  
                                                                            <asp:ImageButton ID="imbEdit" runat="server" ImageUrl="./Images/edit_sm.gif" CommandName="Edit" 
                                                                                ToolTip="Edit this line" />  
                                                                            <asp:ImageButton ID="imbDelete" runat="server" ImageUrl="./Images/delete.gif" CommandName="Delete" 
                                                                                ToolTip="Delete this line" OnClientClick="if(!confirm('Are you sure you want to delete this entry?')) return false;" />  
                                                                            <asp:ImageButton ID="imbInsert" runat="server" ImageUrl="./Images/copy_sm.gif" CommandName="Insert" 
                                                                                ToolTip="Copy this line and insert below" />  
                                                                        </div>  
                                                                        <asp:ImageButton ID="imbHistory" runat="server" ImageUrl="./Images/History.jpg" CommandName="History" 
                                                                            ToolTip="Show History" Visible="false" />  
                                                                    </ItemTemplate>  
                                                                    <EditItemTemplate>  
                                                                        <asp:ImageButton ID="imbUpdate" runat="server" ImageUrl="./Images/SubmitEdit.gif" 
                                                                            CommandName="Update" CommandArgument='<%# Eval("LineID")%>' ToolTip="Accept Changes" 
                                                                            ValidationGroup="valGrpEntry" />  
                                                                        <asp:ImageButton ID="imbCancel" runat="server" ImageUrl="./Images/CancelEdit.gif" 
                                                                            CommandName="Cancel" CommandArgument='<%# Eval("LineID")%>' ToolTip="Cancel Edit" 
                                                                            OnClientClick="if(!confirm('Are you sure you want to cancel any changes?')) return false;" />  
                                                                        <%--<asp:ImageButton ID="imbChange" runat="server" ImageUrl="./Images/ChangeBlue.jpg" 
                                                                            CommandName="Change" ToolTip="Change Description" />--%>  
                                                                    </EditItemTemplate>  
                                                                </telerik:GridTemplateColumn>  
                                                            </Columns>  
                                                        </MasterTableView>  
                                                        <PagerStyle AlwaysVisible="false" Wrap="false" Mode="NextPrevAndNumeric" BorderStyle="None" 
                                                            Position="Bottom" Font-Size="8.5pt" Height="15px"></PagerStyle>  
                                                    </telerik:RadGrid>  
                                                </fieldset>  
                                            </td>  
                                        </tr>  
                                        <tr>  
                                            <td colspan="3" align="right">  
                                                <asp:Button ID="btnAddByExpType2" runat="server" CssClass="innerButton" CausesValidation="false" 
                                                    CommandName="AddByExpType" Text="Add By Expense Type" />  
                                                <asp:Button ID="btnAddByItem2" runat="server" CssClass="innerButton" CausesValidation="false" 
                                                    CommandName="AddByItem" Text="Add By Item" />  
                                            </td>  
                                        </tr>  
                                    </table>  
                                </div>  
                            </telerik:RadPageView>  
                        </telerik:RadMultiPage>  
                    </div>  
                </td>  
            </tr>  
        </table>  
    </div>  
</telerik:RadAjaxPanel>  
<telerik:RadToolTipManager ID="RadToolTipManager1" OffsetY="-20" HideEvent="ManualClose" 
    Animation="None" runat="server" Width="500px" OnAjaxUpdate="OnAjaxUpdate" RelativeTo="Element" 
    Position="MiddleRight">  
</telerik:RadToolTipManager>  
<telerik:RadAjaxLoadingPanel ID="radAjaxLoadingPanel1" Skin="Vista" runat="server">  
</telerik:RadAjaxLoadingPanel>  
<link rel="stylesheet" type="text/css" href="../Styles/Main.css" visible="false" />  
 
        private void grdEntries_ItemCommand(object source, GridCommandEventArgs e)  
        {  
            try 
            {  
                int docType = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["DocType"];  
                int lineID = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["LineID"];  
                string reqNo = (string)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ReqNo"];  
 
                switch (e.CommandName)  
                {  
                    case "Edit":  
                        break;  
                    case "Cancel":  
                        break;  
                    case "Update":  
                        GridDataItem item = (GridDataItem)e.Item;  
                        bool updateCanceled;  
                        string message;  
                        if (UpdateEntry(reqNo, docType, lineID, item, out updateCanceled, out message))  
                        {  
                            RefreshApprovers();  
                            e.Item.Edit = false;  
                            grdEntries.Rebind();  
                            grdApprovers.Rebind();  
                            grdRequestBudget.Rebind();  
                            if (message.Trim().Length == 0)  
                            {  
                                SetSuccessMsg("Request entry is successfully updated.");  
                                SetEntrySuccessMsg(item, "Request entry is successfully updated.");  
                            }  
                            else 
                            {  
                                SetWarningMsg("Request entry is updated with invalid data" + message);  
                                SetEntryWarningMsg(item, "Request entry is updated with invalid data" + message);  
                            }  
                        }  
                        else 
                            SetErrorMsg("Error occurred while updating the entry." + message);  
                        e.Canceled = updateCanceled;  
                        break;  
                    case "Insert":  
                        if (CopyAndInsertAfter(reqNo, docType, lineID))  
                        {  
                            RefreshApprovers();  
                            _selectedEntryLineID = (lineID + 1).ToString();  
                            SetSuccessMsg("Request entry is successfully copied.");  
                            grdEntries.Rebind();  
                            grdApprovers.Rebind();  
                            grdRequestBudget.Rebind();  
                        }  
                        else 
                            SetErrorMsg("Error occurred. Request entry is not copied.");  
                        break;  
                    case "Delete":  
                        if (DeleteEntry(reqNo, docType, lineID))  
                        {  
                            RefreshApprovers();  
                            SetSuccessMsg("Request entry is successfully deleted.");  
                            grdEntries.Rebind();  
                            grdApprovers.Rebind();  
                            grdRequestBudget.Rebind();  
                        }  
                        else 
                            SetErrorMsg("Error occurred. Request entry is not deleted.");  
                        break;  
                    case "MarkReceived":  
                        if (MarkEntryAsReceived(reqNo, docType, lineID))  
                        {  
                            SetSuccessMsg("Request entry is marked as received.");  
                            grdEntries.Rebind();  
                        }  
                        else 
                            SetErrorMsg("Error occurred. Request entry is not marked as received.");  
                        break;  
                    case "ClearReceived":  
                        if (ClearEntryReceivedBy(reqNo, docType, lineID))  
                        {  
                            SetSuccessMsg("Cleared request entry receiver.");  
                            grdEntries.Rebind();  
                        }  
                        else 
                            SetErrorMsg("Error occurred.  Clearing request entry receiver was not successful.");  
                        break;  
                    case "History":  
                        break;  
                }  
            }  
            catch (Exception ex)  
            {  
                switch (e.CommandName)  
                {  
                    case "Edit":  
                        SetErrorMsg("Error opening request entry for edit.");  
                        break;  
                    case "Update":  
                        SetErrorMsg("Error updating request entry.");  
                        break;  
                    case "Insert":  
                        SetErrorMsg("Error copying request entry.");  
                        break;  
                    case "Cancel":  
                        SetErrorMsg("Error cancelling request entry update.");  
                        break;  
                    case "Delete":  
                        SetErrorMsg("Error deleting request entry.");  
                        break;  
                    case "History":  
                        SetErrorMsg("Error showing request entry history.");  
                        break;  
                    case "MarkReceived":  
                        SetErrorMsg("Error occurred while marking request entry as received.");  
                        break;  
                    case "ClearReceived":  
                        SetErrorMsg("Error occurred while clearing request entry as received.");  
                        break;  
                }  
            }  
        }  
 

I removed 90% of the code and left only the part where we are using RadGrid. Look at the one of the TextBoxes and his validator. For instance textbox "itemID". This textbox validated by CustomValidator. If the value is incorrect everything work OK when ItemCommand is not executed. However, when value is OK and IsValid is true, I would like to be able to run ItemCommand when I click on save ("imbUpdate" imageButton).  
0
Iana Tsolova
Telerik team
answered on 04 Jan 2010, 03:12 PM
Hello Pavel,

I went through your code and I observed that you have different ValidationGroup names for the CustomValidator and the Update button. Does it make any difference if you set the controls ValidationGroup property to the same name?
I also used the provided code to prepare a sample project. Could you please check it and let me know if it works as desired or if I missed something from your logic out?

All the best,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Pavel Brokhman
Top achievements
Rank 1
answered on 07 Jan 2010, 12:24 PM
Your example works exactly the same as mine with the problem I try to solve.
Here is the scenario to reproduce it:
1. Click on edit button for "101"
2. Change the value to "101f"
3. Click save. Validation works and show the message
4. Change the value back to "101"
5. Click save. Validation works and message removed. However, save didn't happen, although the value is right
6. You have to click save again to make it happen.

Or another scenario:
1. Click on edit button for "101"
2. Change the value to "101f"
3. Click cancel. I don't want any validation messages, just to cancel it.
0
Iana Tsolova
Telerik team
answered on 07 Jan 2010, 01:26 PM
Hello Pavel,

I followed the listed steps and was able to replicate the behavior. However, the same issue can be replicated if you place the problematic controls outside the grid as well. For instance if the page is as below:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">   
    <asp:TextBox Enabled="true" ID="itemID" MaxLength="20" runat="server" Width="90px"
        AutoPostBack="true" CausesValidation="true" ValidationGroup="valGrpItemID" />
    <asp:CustomValidator ID="custValItemID" Display="Dynamic" class="txtNormal" runat="server"
            ValidateEmptyText="true" OnServerValidate="custValItemID_ServerValidate" ValidationGroup="valGrpItemID"
            Text="<br/>Invalid Expense Type/Item No." />        
    <asp:ImageButton ID="imbUpdate" runat="server" ImageUrl="~/Images/Update.gif" CommandName="Update"
        ToolTip="Accept Changes" ValidationGroup="valGrpItemID" OnClick="imbUpdate_Click" />
    <asp:ImageButton ID="imbCancel" runat="server" ImageUrl="~/Images/Cancel.gif" CommandName="Cancel"
        ToolTip="Cancel Edit" OnClientClick="if(!confirm('Are you sure you want to cancel any changes?')) return false;"
        CausesValidation="false" OnClick="imbCancel_Click" Style="width: 12px" />        
    </form>
</body>
</html>

The this behavior is due to the TextBox AutoPostBack property set to true. Because when you change the TextBox text and without going out of the TextBox focus click on either of the buttons, the TextBox TextChanged event is fired instead of the buttons Click event. And because the TextBox causes validation on postback, validation is fired even when you click on the Cancel button.

Therefore I suggest that you turn the AutoPostBack property of the Textbox back to false. You can use additional button to perform the actions of the TextChanged event handler instead.

I hope this helps.

Best wishes,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Pavel Brokhman
Top achievements
Rank 1
answered on 08 Jan 2010, 01:17 PM
1. I know where the problem is. Why you think I called the topic this way.
2. I never said that the rpblem is the grid. I just used this forum hoping that there is more elegant solution by using Telerik controls to solve it. Because I know the solution to this problem by using JScript. On Client click of the button I put the ID of the button in hidden field. On the server I just check if there is any ID there and imitate button click on server.
3. It is not the solution to remove Autopostback for us, because as I said before, button click it is the only 1 possobility.

P.S. Topic may be closed
Tags
Ajax
Asked by
Pavel Brokhman
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Pavel Brokhman
Top achievements
Rank 1
Share this question
or