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

Server-side ItemCreated event gets called even after client-side RequiredFieldValidator requires input

1 Answer 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Polaris431
Top achievements
Rank 1
Polaris431 asked on 10 Jun 2009, 12:45 PM
In my FormTemplate I have a RadDateTimePicker that is validated using a RequiredFieldValidator. I use a custom Updatebutton to save the fields. The user is required to provide a date in the RadDateTimePicker. The validation does appear to work and the user gets an error message if they fail to provide a date. The problem is, is that the ItemCreated event on the server-side still gets fired when the user presses the Update button. Why is this happening? The grid shouldn't be performing any postbacks when a RequiredFieldValidator indicates that the user must provide input. The whole point of having the validation done on the client-side is to avoid a postback of any kind to the server. Here is the code in my FormTemplate:

<FormTemplate> 
    <table id="tableSessionDetails" cellpadding="5px" cellspacing="0" border="0" style="width: 100%;  
      margin-top: 10px; margin-left: 5px"> 
      <tr> 
        <td style="width: 120px">  
          <asp:Label ID="lblSessionDate" runat="server" Text="Session Date:" CssClass="RadGridDetailsLabel"></asp:Label> 
        </td> 
        <td> 
          <telerik:RadDateTimePicker ID="RadDateTimePickerSessionDate" runat="server" Skin="Sunset">  
          </telerik:RadDateTimePicker> 
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="RadDateTimePickerSessionDate" 
                ErrorMessage="This field is required" runat="server">  
            </asp:RequiredFieldValidator> 
        </td> 
      </tr> 
    </table> 
    <table cellpadding="0" cellspacing="0" border="0" style="margin: 10px; width: 100%">  
      <tr> 
        <td align="right" style="padding-right: 20px; padding-bottom: 10px">  
          <asp:ImageButton ID="imgUpdate" runat="server" ImageUrl="~/images/Update.gif" ToolTip="Update Record" 
            Style="padding-right: 5px" CommandName="Update" /> 
          <asp:ImageButton ID="imgCancel" runat="server" ImageUrl="~/images/Cancel.gif" ToolTip="Cancel Editing" 
            CommandName="Cancel" /> 
        </td> 
      </tr> 
    </table> 
</FormTemplate> 

1 Answer, 1 is accepted

Sort by
0
Polaris431
Top achievements
Rank 1
answered on 10 Jun 2009, 01:53 PM
My web page was using Ajax but the Grid itself was not ajaxifying itself or the validator. I solved the problem with the following code:

<telerik:AjaxSetting AjaxControlID="RadGridDataEntry">  
    <UpdatedControls> 
      <telerik:AjaxUpdatedControl ControlID="RadGridDataEntry" /> 
      <telerik:AjaxUpdatedControl ControlID="RequiredFieldValidator1" /> 
    </UpdatedControls> 
</telerik:AjaxSetting> 
Tags
Grid
Asked by
Polaris431
Top achievements
Rank 1
Answers by
Polaris431
Top achievements
Rank 1
Share this question
or