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

Validation on page button click

1 Answer 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
adel emam
Top achievements
Rank 1
adel emam asked on 24 May 2010, 08:57 AM
hey i hope some one can help me in this roblem
i have grid with with template columns that have  text boxes with its required field validation controls
there is a button outside the grid on the page which save all the values on those text box

what i want when some text box is empty the page never post back ,
i've set validation groups to all button , grid(Validation-setting, text box , validators
but still the validation text show but the page post back


so hope any one can help thanks



<table width="100%">  
<tr><td>Clinical Group:</td><td><telerik:RadComboBox id="cmbClinicalGroups"   
        runat="server" AutoPostBack="True"   
        onselectedindexchanged="cmbClinicalGroups_SelectedIndexChanged"></telerik:RadComboBox></td></tr> 
<tr><td>Services:</td><td><telerik:RadComboBox id="cmbServices" runat="server"></telerik:RadComboBox></td></tr> 
<tr><td></td><td><asp:Button ID="btnLoad" runat="server" onclick="btnLoad_Click"   
        Text="Load" /></td></tr> 
<tr><td colspan="2">  
    <telerik:RadGrid ID="grdServiceFees" runat="server" ValidationSettings-ValidationGroup="save" ValidationSettings-EnableValidation="true"   
        AllowAutomaticDeletes="True" AllowAutomaticInserts="True"   
        AllowAutomaticUpdates="True" AllowFilteringByColumn="True" AllowPaging="True"   
        AllowSorting="True" AutoGenerateColumns="False"   
          
        ShowFooter="True"   
        ShowGroupPanel="True" Width="100%">  
        <ClientSettings AllowColumnsReorder="True" AllowDragToGroup="true"   
            AllowRowsDragDrop="false" Resizing-AllowColumnResize="true"   
            Resizing-AllowRowResize="false">  
            <Selecting AllowRowSelect="True" /> 
            <Scrolling AllowScroll="false" UseStaticHeaders="True" /> 
        </ClientSettings> 
        <MasterTableView AllowAutomaticInserts="false" AllowAutomaticUpdates="false"   
            AllowPaging="true" AllowSorting="true" AutoGenerateColumns="false"   
            CommandItemDisplay="TopAndBottom" DataKeyNames="Id" PageSize="10"   
            RetrieveAllDataFields="false">  
            <CommandItemSettings ShowExportToExcelButton="true"   
                ShowExportToPdfButton="false" ShowExportToWordButton="true" /> 
            <Columns> 
                <telerik:GridTemplateColumn AllowFiltering="true" AutoPostBackOnFilter="true"   
                    DataField="Active" GroupByExpression="Active Group By Active"   
                    HeaderStyle-Width="60px" HeaderText="Active" SortExpression="Active"   
                    UniqueName="Active">  
                    <ItemTemplate> 
                        <asp:Image ID="ImgActive" runat="server" AlternateText="active"   
                            ImageUrl="~/Images/Enabled.png" Visible='<%# bool.Parse(Eval("Active").ToString()) %>' /> 
                        <asp:Image ID="ImgInactive" runat="server" AlternateText="inactive"   
                            ImageUrl="~/Images/Disabled.png" Visible='<%# ! bool.Parse(Eval("Active").ToString()) %>' /> 
                    </ItemTemplate> 
                    <EditItemTemplate> 
                        <asp:CheckBox ID="chkActive" runat="server" Checked="true" /> 
                    </EditItemTemplate> 
                    <HeaderStyle Width="60px" /> 
                </telerik:GridTemplateColumn> 
 
                <telerik:GridBoundColumn AutoPostBackOnFilter="true" DataField="ContractName"   
                    HeaderText="ContractName" UniqueName="ContractName"></telerik:GridBoundColumn> 
 
                    <telerik:GridBoundColumn AutoPostBackOnFilter="true" DataField="PayerName"   
                    HeaderText="PayerName" UniqueName="PayerName">  
                </telerik:GridBoundColumn> 
 
                <telerik:GridTemplateColumn AutoPostBackOnFilter="true" DataField="PatientFee"   
                    HeaderText="PatientFee" UniqueName="PatientFee">  
                    <ItemTemplate> 
                    <asp:TextBox ID="txtPatientFee" runat="server" Value='<%# float.Parse(Eval("PatientFee").ToString()) %>' ValidationGroup="save"></asp:TextBox> 
                    <asp:RequiredFieldValidator ID="patientFeesValidator" runat="server" ControlToValidate="txtPatientFee" ErrorMessage="no" ValidationGroup="save"></asp:RequiredFieldValidator> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
 
                <telerik:GridTemplateColumn AutoPostBackOnFilter="true" DataField="InsuranceFees"   
                    HeaderText="InsuranceFees" UniqueName="InsuranceFees">  
                    <ItemTemplate> 
                    <asp:TextBox ID="txtinsuranceFee" runat="server" Value='<%# float.Parse(Eval("InsuranceFee").ToString()) %>' ValidationGroup="save"></asp:TextBox> 
                    <asp:RequiredFieldValidator ID="insuranceFeesValidator" runat="server" ControlToValidate="txtPatientFee" ErrorMessage="no" ValidationGroup="save"></asp:RequiredFieldValidator> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                  
            </Columns> 
       
            <RowIndicatorColumn> 
                <HeaderStyle Width="20px" /> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn> 
                <HeaderStyle Width="20px" /> 
            </ExpandCollapseColumn> 
        </MasterTableView> 
        <HeaderContextMenu EnableAutoScroll="True">  
        </HeaderContextMenu> 
    </telerik:RadGrid> 
    </td></tr>  
<tr><td></td><td align="right"><asp:Button id="btnSave" Text="Save" runat="server"   
        ValidationGroup="Save" CausesValidation="false" onclick="btnSave_Click" /></td></tr> 
</table> 

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 26 May 2010, 03:40 PM
Hi Аdel,

To achieve the desired functionality you could try setting the Button.ValidationGroup property to "save" (instead of "Save"). Also you need to set Button.CausesValidation property to true.
Additionally I am sending you a simple example, based on your code, which demonstrates how to achieve the desired functionality.

I hoe this helps.

All the best,
Radoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
adel emam
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or