how to set Required field validator for RadAsyncUpload control in side RadGrid.

16 posts, 1 answers
  1. Sairam
    Sairam avatar
    56 posts
    Member since:
    May 2013

    Posted 28 May 2013 Link to this post

    Hello telerik,
    I have requirement like this.....I have " rad grid " with  5 to 6 columns like  rad com-box ,and rad text box 's   apart from that i have "rad async upload" ,how to set required field (or) custom validator to to restrict the user to select some file or image ..how to validate whether
    user is load the image or not .    can provide some snippet ..to validate "rad grid inside rad async upload control"


    <telerik:RadGrid id="RadGrid1" runat="server">
    <MasterTableView>
    <Columns>
    <telerik:RadAsyncUpload Id="RadAsyncUpload1" runat="server"/>
    </Columns>
    </MasteTableView>
    <telerik:RadGrid>

    how to validate the " rad async Upload " Control  through "required filed validator " or"custom validator" in rad grid Insert and Update.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 May 2013 Link to this post

    Hi,

    Try the following code snippet.
     ASPX:
    <telerik:GridTemplateColumn HeaderAbbr="upload" ItemStyle-Width="50%">
     <ItemTemplate>
       <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" TargetFolder="~/Uploads">
       </telerik:RadAsyncUpload>
       <asp:CustomValidator runat="server" ID="CustomValidator" ClientValidationFunction="validateUpload"
         ErrorMessage="Error">
       </asp:CustomValidator>
      </ItemTemplate>
    </telerik:GridTemplateColumn>

    JS:
    function validateUpload(sender, args)
     {
        var grid = $find("<%=Radgrid1.ClientID %>");
        var MasterTable = grid.get_masterTableView();
        for (var i = 0; i < MasterTable.get_dataItems().length; i++)
        {
           var gridItemElement = MasterTable.get_dataItems()[i].findElement("RadAsyncUpload1");
           args.IsValid = gridItemElement.control.getUploadedFiles().length != 0;
        }
     }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sairam
    Sairam avatar
    56 posts
    Member since:
    May 2013

    Posted 29 May 2013 Link to this post

    Thank You ,
    Princy,

    But Validation is not worked ..this my complete code....
    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" Skin="Office2010Silver"
             CssClass="RadGridPosition" ValidationSettings-ValidationGroup="g1">
    <telerik:GridTemplateColumn Visible="true" DataField="Signature" HeaderText="Signature"
                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" UniqueName="Signature">
                        <ItemTemplate>
                            <telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" DataValue='<%#Eval("Signature") is DBNull ? null : Eval("Signature")%>'
                                AutoAdjustImageControlSize="false" ResizeMode="Fit" Height="50px" Width="120px" />
                        </ItemTemplate>
                        <InsertItemTemplate>
                            <telerik:RadAsyncUpload runat="server" ID="ImgImages2" AllowedFileExtensions=".jpg,.jpeg,.png,.gif"
                                MaxFileInputsCount="1" Skin="Outlook" Width="350px" PostbackTriggers="PerformInsertButton" />
                            <asp:CustomValidator runat="server" ID="CustomValidator" ClientValidationFunction="validateUpload"
                                ErrorMessage="Error" />
                        </InsertItemTemplate>
     </telerik:GridTemplateColumn>
     </<telerik:RadGrid>




    And I am written ....u r snippet in rad-code block.

    <script type="text/javascript">
                function validateUpload(sender, args) {
                    var grid = $find("<%=RadGrid1.ClientID %>");
                    var MasterTable = grid.get_masterTableView();
                    for (var i = 0; i < MasterTable.get_dataItems().length; i++) {
                        var gridItemElement = MasterTable.get_dataItems()[i].findElement("ImgImages2");
                        args.IsValid = gridItemElement.control.getUploadedFiles().length != 0;
                    }
                }

            </script>

    where I am done wrong ......can check say correction to me.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 May 2013 Link to this post

    Hi,
    Try the following code snippet to achieve the scenario.

    C#:
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
     {
        if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
        {
            GridEditableItem editableItem = e.Item as GridEditableItem;
            RadAsyncUpload RadAsyncUpload1= editableItem.FindControl("ImgImages2") as RadAsyncUpload;
            HiddenField1.Value =RadAsyncUpload1.ClientID;//to get the upload id
            CustomValidator  CustomValidator1= (CustomValidator)editableItem.FindControl("CustomValidator");
            HiddenField2.Value = CustomValidator1.ClientID;//to get the validator id
        }
     }

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" Skin="Office2010Silver"
             CssClass="RadGridPosition" ValidationSettings-ValidationGroup="g1">
    <telerik:GridTemplateColumn Visible="true" DataField="Signature" HeaderText="Signature"
                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" UniqueName="Signature">
                        <ItemTemplate>
                            <telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" DataValue='<%#Eval("Signature") is DBNull ? null : Eval("Signature")%>'
                                AutoAdjustImageControlSize="false" ResizeMode="Fit" Height="50px" Width="120px" />
                        </ItemTemplate>
                        <InsertItemTemplate>
                            <telerik:RadAsyncUpload runat="server" ID="ImgImages2" AllowedFileExtensions=".jpg,.jpeg,.png,.gif"
                                MaxFileInputsCount="1" Skin="Outlook" Width="350px" PostbackTriggers="PerformInsertButton" />
                            <asp:CustomValidator runat="server" ID="CustomValidator" ClientValidationFunction="validateUpload"
                                ErrorMessage="Error" />
                        </InsertItemTemplate>
     </telerik:GridTemplateColumn>
     </<telerik:RadGrid>
      <asp:HiddenField runat="server" ID="HiddenField1" />
      <asp:HiddenField runat="server" ID="HiddenField2" />


    JS:
    function onFileUploaded(sender, args)
     {
           var CustomValidator = document.getElementById($get("<%=HiddenField2.ClientID %>").value);
           ValidatorValidate(CustomValidator);
     }
    function validateUpload(sender, args)
     {
           var grid = $find("RadGrid1");
           var upload= $find($get("<%=HiddenField1.ClientID %>").value);
           args.IsValid = upload.getUploadedFiles().length != 0;
     }

    Hope this will help you.
    Thanks,
    Princy.
  6. Sairam
    Sairam avatar
    56 posts
    Member since:
    May 2013

    Posted 30 May 2013 Link to this post

    Thanks,
    Princy  ...what is this ...HiddenField1.Value,HiddenField2.Value..what is these I am getting some error here HiddenField1.Value,HiddenField2.Value are  not exist,I am not having any hidden filed..can help me here.give code only i have nothing more than that.
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 May 2013 Link to this post

    Hi,

    I have edited the code,please have a look,add the hidden values as shown in the above code.

    Thanks
    Princy
  8. Sairam
    Sairam avatar
    56 posts
    Member since:
    May 2013

    Posted 30 May 2013 Link to this post

    Thanks ,Princy....sorry to troubles your but problem is not resolved.
    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" Skin="Office2010Silver"
            OnNeedDataSource="RadGrid1_NeedDataSource" OnCancelCommand="RadGrid1_CancelCommand"
            OnDeleteCommand="RadGrid1_DeleteCommand" OnEditCommand="RadGrid1_EditCommand"
            OnInsertCommand="RadGrid1_InsertCommand" OnItemCommand="RadGrid1_ItemCommand"
            OnItemDataBound="RadGrid1_ItemDataBound" OnUpdateCommand="RadGrid1_UpdateCommand"
            OnItemInserted="RadGrid1_ItemInserted" CssClass="RadGridPosition" ValidationSettings-ValidationGroup="g1"
            OnItemCreated="RadGrid1_ItemCreated1">

       <telerik:GridTemplateColumn Visible="true" DataField="Signature" HeaderText="Signature"
                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" UniqueName="Signature">
                        <ItemTemplate>
                            <telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" DataValue='<%#Eval("Signature") is DBNull ? null : Eval("Signature")%>'
                                AutoAdjustImageControlSize="false" ResizeMode="Fit" Height="50px" Width="120px" />
                        </ItemTemplate>
                        <InsertItemTemplate>
                            <telerik:RadAsyncUpload runat="server" ID="ImgImages2" AllowedFileExtensions=".jpg,.jpeg,.png,.gif"
                                MaxFileInputsCount="1" Skin="Outlook" Width="350px" PostbackTriggers="PerformInsertButton" />
                            <asp:CustomValidator runat="server" ID="CustomValidator" ClientValidationFunction="validateUpload"
                                ErrorMessage="Error" />
                            <asp:HiddenField runat="server" ID="HiddenField1" />
                            <asp:HiddenField runat="server" ID="HiddenField2" />
                        </InsertItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadAsyncUpload runat="server" ID="ImgImages" AllowedFileExtensions=".jpg,.jpeg,.png,.gif"
                                MaxFileInputsCount="1" Skin="Outlook" Width="350px" Visible="true" PostbackTriggers="UpdateButton" />
                         
                                Width="200px" />--%>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
    </telerik:RadGrid>

    and check attach error ...i am getting some here....thanks for replay to thread.
  9. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 31 May 2013 Link to this post

    Hi Sairam,

    Please add the HiddenFields outside the radgrid as follows.

    ASPX:

    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" Skin="Office2010Silver"
             CssClass="RadGridPosition" ValidationSettings-ValidationGroup="g1">
    <telerik:GridTemplateColumn Visible="true" DataField="Signature" HeaderText="Signature"
                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" UniqueName="Signature">
                        <ItemTemplate>
                            <telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" DataValue='<%#Eval("Signature") is DBNull ? null : Eval("Signature")%>'
                                AutoAdjustImageControlSize="false" ResizeMode="Fit" Height="50px" Width="120px" />
                        </ItemTemplate>
                        <InsertItemTemplate>
                            <telerik:RadAsyncUpload runat="server" ID="ImgImages2" AllowedFileExtensions=".jpg,.jpeg,.png,.gif"
                                MaxFileInputsCount="1" Skin="Outlook" Width="350px" PostbackTriggers="PerformInsertButton" />
                            <asp:CustomValidator runat="server" ID="CustomValidator" ClientValidationFunction="validateUpload"
                                ErrorMessage="Error" />
                        </InsertItemTemplate>
     </telerik:GridTemplateColumn>
     </<telerik:RadGrid>
     
    <%-- Place the hidden fields outside the radgrid,like this--%>
     
      <asp:HiddenField runat="server" ID="HiddenField1" />
      <asp:HiddenField runat="server" ID="HiddenField2" />

    Thanks
    Princy
  10. Sairam
    Sairam avatar
    56 posts
    Member since:
    May 2013

    Posted 31 May 2013 Link to this post

    Thanks Princy,all fine error message not shown to me....this entire code

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default12.aspx.cs" Inherits="Default12" %>

    <%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
     
        <form id="form1" runat="server">
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function onFileUploaded(sender, args) {
                    var CustomValidator = document.getElementById($get("<%=HiddenField2.ClientID %>").value);
                    ValidatorValidate(CustomValidator);
                }
                </script>
                 <script type="text/javascript">
                function validateUpload(sender, args) {
                    var grid = $find("RadGrid1");
                    var upload = $find($get("<%=HiddenField1.ClientID %>").value);
                    args.IsValid = upload.getUploadedFiles().length != 0;
                }
            </script>
        </telerik:RadCodeBlock>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <div>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel" runat="server">
            </telerik:RadAjaxLoadingPanel>
            <telerik:RadGrid ID="RadGrid1" runat="server"
                onitemcreated="RadGrid1_ItemCreated" onneeddatasource="RadGrid1_NeedDataSource">
                <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="false">
                    <CommandItemSettings ShowAddNewRecordButton="true" ShowRefreshButton="true" />
                    <Columns>
                        <telerik:GridTemplateColumn>
                            <InsertItemTemplate>
                                <telerik:RadAsyncUpload ID="RadAsyncUpload" runat="server" PostbackTriggers="PerformInsertButton">
                                </telerik:RadAsyncUpload>
                                <asp:CustomValidator runat="server" ID="CustomValidator" ClientValidationFunction="validateUpload"
                                    ErrorMessage="Error" ForeColor="Red" />
                             </InsertItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn>
                   <InsertItemTemplate>
                   <telerik:RadTextBox ID="RadTextBox1" runat="server">
                   </telerik:RadTextBox>
                   <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"  ControlToValidate="RadTextBox1" ErrorMessage="error" ForeColor="Red"></asp:RequiredFieldValidator>
                   </InsertItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                    <EditFormSettings InsertCaption="New Check details" CaptionDataField="chkType" CaptionFormatString="Edit & Update Check">
                        <EditColumn UniqueName="imgcolEdit" ButtonType="ImageButton" CancelImageUrl="images/Cancel.gif"
                            UpdateImageUrl="images/update.gif" InsertImageUrl="images/update.gif">
                        </EditColumn>
                        <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow1"></FormTableButtonRowStyle>
                    </EditFormSettings>
                </MasterTableView>
            </telerik:RadGrid>
            <asp:HiddenField runat="server" ID="HiddenField1" />
            <asp:HiddenField runat="server" ID="HiddenField2" />
        </div>
        </form>
    </body>
    </html>

    aspx.cs
    public partial class Default12 : System.Web.UI.Page
    {
        MySqlConnection m_oConn = new MySqlConnection(ConfigurationManager.ConnectionStrings["m_oConn"].ConnectionString);
        MySqlCommand m_oCmd;
        MySqlDataAdapter m_aDp;
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            m_oCmd = new MySqlCommand("select * from  tbl_TaxSetUp", m_oConn);
            m_aDp = new MySqlDataAdapter(m_oCmd);
            DataSet ds = new DataSet();
            if (m_aDp.Fill(ds) >= 0)
            {
                RadGrid1.DataSource = ds.Tables[0].DefaultView;
            }
        }
        protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
            {
                GridEditableItem editableItem = e.Item as GridEditableItem;
                RadAsyncUpload RadAsyncUpload1 = editableItem.FindControl("RadAsyncUpload") as RadAsyncUpload;
                HiddenField1.Value = RadAsyncUpload1.ClientID;//to get the upload id
                CustomValidator CustomValidator1 = (CustomValidator)editableItem.FindControl("CustomValidator");
                HiddenField2.Value = CustomValidator1.ClientID;//to get the validator id
            }
        }
    }

    error message not like required file  validator 
  11. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 03 Jun 2013 Link to this post

    Hi Sairam,

    At the moment you Ajaxify your grid, but the hidden fields are outside the grid and their values are not changed from the server as they are not posted on the Ajax request. Try to put them inside RadAjaxPanel:
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px" LoadingPanelID="RadAjaxLoadingPanel">
          <telerik:RadGrid ID="RadGrid1" runat="server"
              OnItemCreated="RadGrid1_ItemCreated" OnNeedDataSource="RadGrid1_NeedDataSource">
              <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="false">
                  <CommandItemSettings ShowAddNewRecordButton="true" ShowRefreshButton="true" />
                  <Columns>
                      <telerik:GridTemplateColumn>
                          <InsertItemTemplate>
                              <telerik:RadAsyncUpload ID="RadAsyncUpload" runat="server" PostbackTriggers="PerformInsertButton" OnClientFileUploaded="onFileUploaded">
                              </telerik:RadAsyncUpload>
                              <asp:CustomValidator runat="server" ID="CustomValidator" ClientValidationFunction="validateUpload"
                                  ErrorMessage="Error" ForeColor="Red" />
                          </InsertItemTemplate>
                      </telerik:GridTemplateColumn>
                      <telerik:GridTemplateColumn>
                          <InsertItemTemplate>
                              <telerik:RadTextBox ID="RadTextBox1" runat="server">
                              </telerik:RadTextBox>
                              <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="RadTextBox1" ErrorMessage="error" ForeColor="Red"></asp:RequiredFieldValidator>
                          </InsertItemTemplate>
                      </telerik:GridTemplateColumn>
                  </Columns>
                  <EditFormSettings InsertCaption="New Check details" CaptionDataField="chkType" CaptionFormatString="Edit & Update Check">
                      <EditColumn UniqueName="imgcolEdit" ButtonType="ImageButton" CancelImageUrl="images/Cancel.gif"
                          UpdateImageUrl="images/update.gif" InsertImageUrl="images/update.gif">
                      </EditColumn>
                      <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow1"></FormTableButtonRowStyle>
                  </EditFormSettings>
              </MasterTableView>
          </telerik:RadGrid>
          <asp:HiddenField runat="server" ID="HiddenField1" />
          <asp:HiddenField runat="server" ID="HiddenField2" />
      </telerik:RadAjaxPanel>


    Regards,
    Hristo Valyavicharski
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  12. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Jun 2013 Link to this post

    Hi,

    I guess you want to show the custom Validator error message similar to Required field valiadtor. Please check the following code snippet.

    ASPX:
    <telerik:GridTemplateColumn>
        <InsertItemTemplate>
            <telerik:RadAsyncUpload ID="RadAsyncUpload" runat="server" PostbackTriggers="PerformInsertButton">
            </telerik:RadAsyncUpload>
            <asp:CustomValidator runat="server" ID="CustomValidator" ClientValidationFunction="validateUpload"
                ErrorMessage="Error" ForeColor="Red" CssClass="CustomCSS" />
        </InsertItemTemplate>
    </telerik:GridTemplateColumn>

    CSS:
    <style type="text/css">
        .custom
        {
            margin-left: 208px;
            margin-top: -26px;
            position: absolute;
        }
    </style>

    Thanks,
    Princy.
  13. Sairam
    Sairam avatar
    56 posts
    Member since:
    May 2013

    Posted 03 Jun 2013 Link to this post

    Very very Thanks,Princy ....It's working.....remove from Rad grid From Ajax Settings...... Thanks Once again princy
  14. Gustavo
    Gustavo avatar
    26 posts
    Member since:
    Jun 2014

    Posted 28 Aug 2014 in reply to Princy Link to this post

    Hi  prince 

    Actually, I have the same problem the radasyncupload on edit but 
    on the method _ItemCreated(object sender, GridItemEventArgs e) never i dont enter to execute the code

    regards
  15. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 Aug 2014 in reply to Gustavo Link to this post

    Hi Gustavo,

    Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadGrid ID="rgridOrders" runat="server" DataSourceID="sqldsOrders" CellSpacing="-1"
        GridLines="Both" ResolvedRenderMode="Classic" AutoGenerateEditColumn="true" OnItemCreated="rgridOrders_ItemCreated">
        <MasterTableView DataSourceID="sqldsOrders" CommandItemDisplay="Top" AutoGenerateColumns="False" DataKeyNames="OrderID">
            <Columns>
                <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" FilterControlAltText="Filter OrderID column"  HeaderText="OrderID" ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn>
                    <EditItemTemplate>
                        <telerik:RadAsyncUpload runat="server" ID="ImgImages2" AllowedFileExtensions=".jpg,.jpeg,.png,.gif" MaxFileInputsCount="1" Skin="Outlook" Width="350px" PostbackTriggers="PerformInsertButton" />
                        <asp:CustomValidator runat="server" ID="CustomValidator" ClientValidationFunction="validateUpload" ErrorMessage="Error" />
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <asp:HiddenField runat="server" ID="HiddenField1" />
    <asp:HiddenField runat="server" ID="HiddenField2" />

    C#:
    protected void rgridOrders_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem editableItem = e.Item as GridEditableItem;
            RadAsyncUpload RadAsyncUpload1 = editableItem.FindControl("ImgImages2") as RadAsyncUpload;
            HiddenField1.Value = RadAsyncUpload1.ClientID;//to get the upload id
            CustomValidator CustomValidator1 = (CustomValidator)editableItem.FindControl("CustomValidator");
            HiddenField2.Value = CustomValidator1.ClientID;//to get the validator id
        }
    }

    JavaScript:
    function onFileUploaded(sender, args) {
        var CustomValidator = document.getElementById($get("<%=HiddenField2.ClientID %>").value);
        ValidatorValidate(CustomValidator);
    }
    function validateUpload(sender, args) {
        var grid = $find("RadGrid1");
        var upload = $find($get("<%=HiddenField1.ClientID %>").value);
        args.IsValid = upload.getUploadedFiles().length != 0;
    }

    Thanks,
    Princy.
  16. Gustavo
    Gustavo avatar
    26 posts
    Member since:
    Jun 2014

    Posted 29 Aug 2014 in reply to Princy Link to this post

    Hi,
    thanks this example run very well but i develop the follow code

    first I use the  <CommandItemTemplate> &  CommandName="InitInsert" for a button int he header the grid
    second  I use the  <InsertItemTemplate>
    third   I use  protected   void rdGrdEnerguia_ItemCreated(object sender, GridItemEventArgs e)
                                         if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)

    the error it ocurrs when run the javascript that it doesnt exist the element , i debug the code and never it enter to event


    thanks & regards






  17. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 02 Sep 2014 Link to this post

    Hi Gustavo,

    Does it work on Chrome or Firefox? If so then the issue is casued by the AsyncUpload's Upload Modules.

    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017