How do I get RadUpload additional field value at clientside

Thread is closed for posting
4 posts, 1 answers
  1. kevin yang
    kevin yang avatar
    15 posts
    Member since:
    Dec 2009

    Posted 19 Jul 2010 Link to this post

                        <telerik:RadGrid ID="rgGrid" runat="server" AutoGenerateColumns="False" AllowAutomaticInserts="True"
                            AllowAutomaticDeletes="True" AllowAutomaticUpdates="True" DataSourceID="ldsProfiles"
                            GridLines="None" Skin="Office2007" BorderWidth="0px" OnItemCommand="rgGrid_ItemCommand"
                            OnItemUpdated="rgGrid_ItemUpdated" OnItemInserted="rgGrid_ItemInserted" OnItemCreated="rgGrid_ItemCreated"  >
                            <MasterTableView DataKeyNames="ProposalAttachmentID" DataSourceID="ldsProfiles"
                                EditMode="EditForms" CommandItemDisplay="Top" >
                                <CommandItemStyle CssClass="gridHeader" />
                                    <div class="gridHeader">
                                    <div class="sectionHeaderButton" style="margin-left: 10px;">
                                        <asp:LinkButton ID="rgProAddButton" runat="server" Text="(add)" CommandName="InitInsert" Visible='<%# 
    !rgGrid.MasterTableView.IsItemInserted   %>' />
                                    <telerik:GridBoundColumn DataField="UploadDate" DataType="System.DateTime" HeaderText="Date"
                                        ForceExtractValue="InEditMode" ReadOnly="true" SortExpression="UploadDate"
                                        UniqueName="UploadDate" DataFormatString="{0:MM/dd/yyyy}" ItemStyle-Width="13%">
    <ItemStyle Width="13%"></ItemStyle>
                                    <telerik:GridBoundColumn DataField="User.FullName" DataType="System.String" HeaderText="Author"
                                        ForceExtractValue="InEditMode" ReadOnly="true" SortExpression="User.FirstName"
                                        UniqueName="User.FullName" ItemStyle-Width="15%">
    <ItemStyle Width="15%"></ItemStyle>
                                    <telerik:GridTemplateColumn DataField="FileName" HeaderText="File" SortExpression="FileName"
                                        UniqueName="FileName" EditFormHeaderTextFormat="">
                                            <asp:HyperLink ID="lbPorfiles" runat="server"  NavigateUrl='<%# UploadPath+"/"+Eval("ProposalFK")+"/"+ Eval("User.Login") 
    +"/"+ Eval("FileName")%>' Target="_blank"  Text='<%# Bind("FileName")%>'></asp:HyperLink>
                                            <div style="left">
                                                <telerik:RadUpload ID="rdProfile" runat="server" InitialFileInputsCount="1"  
                                                    MaxFileInputsCount="5" Localization-Add="Add More Files" EnableFileInputSkinning="true"
                                                    ControlObjectsVisibility="AddButton" MaxFileSize="1000000" OnClientFileSelected="ValidateExtension"   
                                                    AllowedFileExtensions=".doc,.pdf,.ppt,.xls" OnClientAdded="addTitle" Skin="Office2007" 
                                                    Width="95%" InputSize="35">  
                                                    <Localization Add="Add More Files" />
                                                <span id="fileExtentionError" class="error" style="display:none; color:#cc0000; font-weight:bold">* Invalid file 
    extensions. Only the following file formats can be uploaded: .doc,.pdf,.ppt,.xls</span
                                                <span id="nullDescriptionError" class="error" style="display:none; color:#cc0000; font-weight:bold">* Please enter 
                                                <span id="overDescriptionError" class="error" style="display:none; color:#cc0000; font-weight:bold">* Please limit 
    Description to 150 characters or less</span>                                                                                         
                                                <asp:CustomValidator Text="" runat="server" ID="FileUploadValidator" OnServerValidate="FileUpload_ServerValidate" 
    ClientValidationFunction="ValidateFileUpload" />
                                                <%--        *Invalid file extensions. Only the following file formats can be uploaded: .doc,.pdf,.ppt,.xls
                                                </asp:CustomValidator> --%>                                                                                   
                                                <script type="text/javascript">
                                                    function ValidateFileUpload(source, arguments)
                                                        var radGrid = $find('<%= rgGrid.ClientID %>');
                                                        var radUpload = $telerik.findControl(radGrid.get_element(), "rdProfile");
                                                        var fileInputs = radUpload.getFileInputs()
                                                        var isValid = true;
                                                        //var descValue = $get('<%= rgGrid.ClientID %>' + 'Title' + i).value
                                                        var descValue = $get(radUpload.getID() + 'Title' + i).value                                                    
                                                        for (var i = 0; i < fileInputs.length; i++)
                                                        arguments.IsValid = isValid;
                                                    var i = 0
                                                    function addTitle(sender, args)
                                                        var inputRow = args.get_row();
                                                        var fileInputSpan = inputRow.getElementsByTagName("span")[0];
                                                        var tAddField = sender.getID("Title");
                                                        $(".ruInputs li[class='']:last span").after($("<textarea rows=3 cols='50'/>").attr("id", tAddField).attr("name", 
    tAddField)).after($("<label class='fileInputLabel'>Description : </label>").attr("for", tAddField)).before($("<label class='fileInputLabel'>  File : 
    </label>").attr("for", fileInputSpan));                                         
    I have a RadUpload control in EditTemplate inside a RadGrid.
    I add the client code to add addtional field with TextArea type allowing user to enter comment for the uploading file.
    And that additional comment field is a required field, also only 500 characters max limited.
    I want a TextArea type because I want to user to see all the text they enter and input type=text just won't do the justification.
    I seem to have a problem to get the addional field's value at client side code. 

    I use  
       var radGrid = $find('<%= rgGrid.ClientID %>');

    to get the grid control
       var radUpload = $telerik.findControl(radGrid.get_element(), "rdProfile");
    to get the upload control

    When I try to retrive the value of the additional field by code similar to
       var descValue = $get(radUpload.getID() + 'Title' + i).value 
    I am getting javascript error saying "object needed"

    Anyone can help?
    I attached my code

  2. kevin yang
    kevin yang avatar
    15 posts
    Member since:
    Dec 2009

    Posted 20 Jul 2010 Link to this post

    Any help from Telerik Support Team?
  3. DevCraft R3 2016 release webinar banner
  4. Answer
    Yana avatar
    4547 posts

    Posted 21 Jul 2010 Link to this post

    Hello Kevin,

    Actually the correct client method to get the id is get_id(), not getID(), please replace it like this:

    var descValue = $get(radUpload.get_id() + 'Title' + i).value

    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
  5. kevin yang
    kevin yang avatar
    15 posts
    Member since:
    Dec 2009

    Posted 21 Jul 2010 Link to this post

    Yes, that solves the problem, thanks
Back to Top