Click here to Skip to main content
15,907,396 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am passing all grid data from form tag to controller but getting incomplete data so giving error while parsing "Unterminated string. Expected delimiter"

//code in view
C#
function Export_PDF() {
        var grid = $("#grid").data("kendoGrid");
        var dataSource = (grid != null) ? grid.dataSource : null;
        var filters = (grid != null) ? dataSource.filter() : null;
        var allData = dataSource.data();
        var query = new kendo.data.Query(allData);
        var data = query.filter(filters).data;
        var dataJSON = JSON.stringify(data);        

     
            $('body').prepend("<form method='post' action='Print_PDF_EX' style='top:-3333333333px;' id='tempForm'><input type='hidden' name='data' value='" + dataJSON + "' ></form>");
            $('#tempForm').submit();
       
    }


//in controller accessing form data
string gridData = Request.Form["data"]; // getting icomplete data
//parsing data
JArray results = JArray.Parse(gridData); //here getting above error
Posted
Comments
Kornfeld Eliyahu Peter 26-May-14 6:30am    
It a complete mess! You are adding form on the fly BEFORE the body!!! And you expect to get form values on the server side!?
Member 9579525 26-May-14 6:39am    
but i am getting values..problem is that when there is large data in grid then not getting all data so while parsing getting error...i am creating form on click and passing data form it..if i am wrong then how to send all grid data to controller?
Thanks7872 26-May-14 7:02am    
use reply button at comment that way you can notify him.

1 solution

Even there is no theoretical limit for the size of the post all known implementations limit it. In IIS it is about 4Kb (MaxClientRequestBuffer), in Appache it is unlimited by default but can be changed (LimitRequestBody)...
So, if your data is large enough it will be cut...
In any way your solution is a complete mess...Learn using your tools - KendoUI has built in capabilities to post data to server, you also can use jQuery.ajax variations...
 
Share this answer
 
Comments
Member 9579525 26-May-14 8:04am    
i have tried using ajax also, by it getting all data but not opening dialogue box to open/save pdf
//code
$.ajax({
url: '@Url.Action("Print_PDF", "Controller_Name")',
dataType: 'json',
data: {
gridData: dataJSON
},
ContentType:'application/json; charset=utf-8',
traditional: true,
type: 'POST',
success: OnComplete,
error: OnFail
});

function OnComplete(result) {
alert(result);
}

function OnFail(result) {
alert("OnFail");
}

in controller return type is return File(stream,"application/pdf",filename,);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900