Invalid JSON primitive : filename at radgrid?

4 posts, 0 answers
  1. Madhu Palakurthi
    Madhu Palakurthi avatar
    48 posts
    Member since:
    Nov 2009

    Posted 14 May 2013 Link to this post

    Hi,

    I have a problem with telerik version 2013.1.417.35 for radasyncupload in the grid. I dont have any problem with previous versions.

    I have a grid and trying to create a new attachment gives an error : 

    <telerik:RadGrid ID="AttachmentGrid" GridLines="None" EnableLinqExpressions="False"
                runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
                AllowPaging="True" DataSourceID="SubActivitiesDataSource" Skin="Metro" AllowSorting="True"
                AutoGenerateDeleteColumn="False" OnItemCommand="AttachmentGrid_ItemCommand" OnItemCreated="AttachmentGrid_ItemCreated">
                <PagerStyle Mode="NextPrevAndNumeric" />
                <%--25/03/2013--%>
                <MasterTableView Width="110%" Height="400px" CommandItemDisplay="Top" DataKeyNames="id"
                    DataSourceID="AttachmentDataSource" HorizontalAlign="NotSet" AutoGenerateColumns="False"
                    EditMode="PopUp" CommandItemSettings-AddNewRecordText="Add New Attachment">
                    <CommandItemSettings ExportToPdfText="Export to Pdf" />
                    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                        <HeaderStyle Width="20px" />
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                        <HeaderStyle Width="20px" />
                    </ExpandCollapseColumn>
                    <EditFormSettings InsertCaption="Add New Attachment" EditColumn-UpdateText="Save"
                        EditColumn-InsertText="Save" EditColumn-ButtonType="PushButton" FormMainTableStyle-Height="250">
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                        </EditColumn>
                        <PopUpSettings Modal="true" ZIndex="999999" CloseButtonToolTip="Click to close" Width="800" />
                    </EditFormSettings>
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="LinkButton" EditText="Edit">
                            <ItemStyle Font-Size="Small" Font-Bold="true" />
                        </telerik:GridEditCommandColumn>
                        <telerik:GridButtonColumn ButtonType="LinkButton" Text="Delete" CommandName="Delete"
                            ConfirmText="Are you sure?" ConfirmTitle="Alert">
                            <ItemStyle Font-Size="Small" Font-Bold="true" />
                        </telerik:GridButtonColumn>
                        <telerik:GridTemplateColumn UniqueName="InitiatorName" Groupable="False" HeaderText="Which entity or company did you receive this file from?"
                            DataField="InitiatorName" Display="false">
                            <ItemTemplate>
                                <asp:Label ID="lblcompany" Text='<%#DataBinder.Eval(Container.DataItem, "InitiatorName")%>'
                                    runat="server"  Display="false"></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="InitiatorName" runat="server" CssClass="textbox" SelectedValue='<%# Bind("InitiatorName") %>'
                                    DataSourceID="CompanyNameDataSource" DataTextField="InitiatorName" Width="300px"
                                    DataValueField="InitiatorName" OnSelectedIndexChanged="InitiatorName_SelectedIndexChanged"
                                    AutoPostBack="true">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="ReqInitiatorName" runat="server" ControlToValidate="InitiatorName"
                                    ErrorMessage="Please Select a Company Name" Display="Dynamic" SetFocusOnError="true" />
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="FileMainCategory" Groupable="False" HeaderText="Which of the 6 chapters"
                            DataField="FileMainCategory">
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "FileMainCategory")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="FileMainCategory" runat="server" CssClass="textbox" SelectedValue='<%# Bind("FileMainCategory") %>'
                                    DataSourceID="FileMainCategoryDataSource" DataTextField="MainCategory" Width="300px"
                                    DataValueField="MainCategory" OnSelectedIndexChanged="MainCategory_SelectedIndexChanged"
                                    AutoPostBack="true">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredfieldvalidatorFileMainCategory" runat="server"
                                    ControlToValidate="FileMainCategory" ErrorMessage="Please select one, if none applies then choose “Others”"
                                    Display="Dynamic" SetFocusOnError="true" />
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="FileCategory" Groupable="False" HeaderText="Categorise this file based on the 6 Chapters selected"
                            DataField="FileCategory">
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "FileCategory")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="FileCategory1" runat="server" CssClass="textbox" DataTextField="Category"
                                    Width="300px" DataSourceID="FileCategoryDataSource" DataValueField="Category">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredfieldvalidatorFileCategory" runat="server"
                                    ControlToValidate="FileCategory1" ErrorMessage="Please Select a File Category"
                                    Display="Dynamic" SetFocusOnError="true" />
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="MainClassofInsurance" Groupable="False" HeaderText="Is this related to a particular class of insurance?"
                            DataField="MainClassofInsurance"  Display="false">
                            <ItemTemplate>
                                <asp:Label ID="lblClassofInsurance" Text='<%#DataBinder.Eval(Container.DataItem, "MainClassofInsurance")%>'
                                    runat="server"  Display="false"></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="MainClassofInsurance" runat="server" CssClass="textbox" SelectedValue='<%# Bind("MainClassofInsurance") %>'
                                    DataSourceID="ClassOfInsurancedatasource" DataTextField="Insurance" Width="300px"
                                    DataValueField="Insurance" OnSelectedIndexChanged="MainClassofInsurance_SelectedIndexChanged"
                                    AutoPostBack="true">
                                </asp:DropDownList>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <%--24/03/2012 --%>
                        <telerik:GridTemplateColumn UniqueName="refid" Groupable="False" HeaderText="TaskNo"
                            DataField="refid">
                            <ItemTemplate>
                                <%-- Start-14/12/2012-Reddy Set InitiatorName/MainClassofInsurance values from task master unless exist in the attachment table.--%>
                                <asp:HyperLink ID="lnkrefid" runat="Server" NavigateUrl='<%#"~/EditTask.aspx?TaskNo=" + DataBinder.Eval(Container.DataItem, "refid").ToString()%>'
                                    Text='<%# Bind("refid") %>' Target="_blank" />
                                <%--<%#DataBinder.Eval(Container.DataItem, "refid")%>--%>
                                <%--End-14/12/2012-Reddy Set InitiatorName/MainClassofInsurance values from task master unless exist in the attachment table.--%>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="emailrefid" Groupable="False" HeaderText="emailrefid"
                            DataField="emailrefid">
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "emailrefid")%>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <%--24/03/2012--%>
                        <telerik:GridTemplateColumn UniqueName="Status" Groupable="False" HeaderText="Status"
                            FilterControlWidth="50px">
                            <HeaderStyle Width="80px" />
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "Status")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="Status" runat="server" SelectedValue='<%# Bind("Status") %>'
                                    CssClass="textbox">
                                    <asp:ListItem Text="ACTIVE" Value="ACTIVE" Selected="True"></asp:ListItem>
                                    <asp:ListItem Text="INACTIVE" Value="INACTIVE"></asp:ListItem>
                                    <asp:ListItem Text="DELETED" Value="DELETED"></asp:ListItem>
                                    <asp:ListItem Text="Please Select" Value=""></asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredfieldvalidatorStatus" runat="server" ControlToValidate="Status"
                                    ErrorMessage="Please Select a Status" Display="Dynamic" SetFocusOnError="true" />
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridAttachmentColumn DataSourceID="SubActivitiesDataSource" MaxFileSize="10048576"
                            HeaderStyle-Font-Bold="true" EditFormHeaderTextFormat="Upload File: " HeaderText="Attachment"
                            AttachmentDataField="Content" AttachmentKeyFields="id" FileNameTextField="FileName"
                            DataTextField="FileName" UniqueName="AttachmentColumn" AllowFiltering="true">
                        </telerik:GridAttachmentColumn>
                        <telerik:GridTemplateColumn UniqueName="filename" Groupable="False" HeaderText="File Name"
                            DataField="filename">
                            <HeaderStyle Width="150px" />
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "filename")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtFile" Text='<%# Bind("filename") %>' runat="server"></asp:TextBox>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="Description" Groupable="False" HeaderText="Description"
                            DataField="Description">
                            <HeaderStyle Width="150px" />
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "Description")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtdesc" Text='<%# Bind("Description") %>' runat="server" Width="400px"
                                    Height="50px" TextMode="MultiLine"></asp:TextBox>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <%--25/03/2013--%>
                        <telerik:GridTemplateColumn UniqueName="DateUpdated" Groupable="False" HeaderText="Date Created">
                            <HeaderStyle Width="150px" />
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "DateUpdated")%><br />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="UpdatedBy" Groupable="False" HeaderText="Created By">
                            <HeaderStyle Width="150px" />
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "UpdatedBy")%>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <%--25/03/2013--%>
                        <%-- ssy       '01/08/2012--%>
                        <telerik:GridTemplateColumn UniqueName="PlacementNo" Groupable="False" HeaderText="PlacementNo"
                            DataField="PlacementNo">
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "PlacementNo")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtPlacementNo" Text='<%# Bind("PlacementNo") %>' runat="server"></asp:TextBox>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="AddendumNo" Groupable="False" HeaderText="AddendumNo"
                            DataField="AddendumNo">
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "AddendumNo")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtAddendumNo" Text='<%# Bind("AddendumNo") %>' runat="server"></asp:TextBox>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="ClaimNo" Groupable="False" HeaderText="ClaimNo"
                            DataField="ClaimNo">
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "ClaimNo")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtClaimNo" Text='<%# Bind("ClaimNo") %>' runat="server"></asp:TextBox>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="EndorsementNo" Groupable="False" HeaderText="EndorsementNo"
                            DataField="EndorsementNo">
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "EndorsementNo")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtEndorsementNo" Text='<%# Bind("EndorsementNo") %>' runat="server"></asp:TextBox>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="OtherRefNo" Groupable="False" HeaderText="OtherRefNo"
                            DataField="OtherRefNo">
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "OtherRefNo")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtOtherRefNo" Text='<%# Bind("OtherRefNo") %>' runat="server"></asp:TextBox>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="GroupName" Groupable="False" HeaderText="GroupName"
                            DataField="GroupName">
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "GroupName")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtGroupName" Text='<%# Bind("GroupName") %>' runat="server"></asp:TextBox>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn UniqueName="PolicyYear" Groupable="False" HeaderText="PolicyYear"
                            DataField="PolicyYear">
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "PolicyYear")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtPolicyYear" Text='<%# Bind("PolicyYear") %>' runat="server"></asp:TextBox>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <%-- ssy       '01/08/2012--%>
                    </Columns>
                </MasterTableView>
                <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Sunset">
                </HeaderContextMenu>
                <ClientSettings>
                    <Selecting AllowRowSelect="True" />
                    <%--25/03/2013--%>
                    <Scrolling AllowScroll="true" />
                    <%--25/03/2013--%>                
                </ClientSettings>
                <FilterMenu EnableImageSprites="False">
                </FilterMenu>
            </telerik:RadGrid>

    after upload a file then click on save button gives an error - Invalid JSON primitive : filename.

    it' not hitting any break point .. so unable to solve this...

    please help me on this..

    Thanks in advance..

  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 16 May 2013 Link to this post

    Hi Narsa,

    Would you specify where do you define RadAsyncUpload? Is it in the code behind? How do you upload files? The described issue could not be reproduced from the pasted markup. Please send a runnable sample with steps to reproduce so we can debug your code and troubleshoot the problem.

    Regards,
    Hristo Valyavicharski
    the Telerik team
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Madhu Palakurthi
    Madhu Palakurthi avatar
    48 posts
    Member since:
    Nov 2009

    Posted 16 May 2013 Link to this post

    Hi,

    This problem solved myself.

    When I am uploading file from upload control then showing file name in to other textbox.
    Protected Sub AttachmentGrid_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs)
         If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
             Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)
             Dim upload As RadUpload = (TryCast(item.EditManager.GetColumnEditor("AttachmentColumn"), GridAttachmentColumnEditor)).RadUploadControl
             upload.OnClientFileSelected = "uploadFileSelected"
             
         End If
     End Sub

    function uploadFileSelected(sender, args) {
               upload = sender;
               var uploadContainer = sender.get_element();
               var editTable = uploadContainer.parentNode.parentNode.parentNode.parentNode;
               var fileNameTextBox = editTable.rows[7].cells[1].getElementsByTagName('input')[0];
     
               fileNameTextBox.value = showFile(args.get_fileInputField().title);
           }

    From above code i have given wrong row index (editTable.rows[6].cells[1] ) , So then it's throwing an JSON error.

    I dont know why If i give wrong row index throwing JSON error..

    Thank you.
  5. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 17 May 2013 Link to this post

    Hi Narsa,

    Thank you for sharing this with the community.

    Regards,
    Hristo Valyavicharski
    the Telerik team
    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.
Back to Top