Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am getting the error too many characters in literal in the below statement of javascript

'' + '<%: Html.ActionLink(' + lstItems[ind] + ',"ReDirectToDetails", "ECU", new {ECSiD = ' + lstItems[ind] + '}) %>;' + '' +

Please help me on this.

What I have tried:

I am getting the error too many characters in literal in the below statement of javascript

'' + '<%: Html.ActionLink(' + lstItems[ind] + ',"ReDirectToDetails", "ECU", new {ECSiD = ' + lstItems[ind] + '}) %>;' + '' +

Please help me on this.
Posted
Updated 7-Jul-17 4:57am
Comments
Richard Deeming 7-Jul-17 9:27am    
Is lstItems a variable defined in Javascript?

If so, you can't do it like that. Javascript runs on the client, after the server-side code has executed and rendered the response. You can't pass a Javascript variable to a server-side method.
Patrice T 7-Jul-17 15:59pm    
Try to show a real piece of code.
Member 8557048 10-Jul-17 3:40am    
In document.ready() function I have written like below
var txtShipID = "<%:Model.ShipID %>";
var txtShipItems = "<%:Model.ShipItems%>";
var lstItems = txtShipItems.split(',');
var table = "";
for (var ind = 0; ind < lstItems.length; ind++) {

var row = $('' +
'' +
'' +

'' +
'');
$('#tblShipping').append(row);
}
});

After running the code I a getting the mentioned error.' + lstItems[ind].substring(0, 3) + '' + '<%: Html.ActionLink('+lstItems[ind]+',"ReDirectToDetails", "ECU", new {' + lstItems[ind] +'}) %>' + '' + 'Delete' + '

1 solution

My experience says that the error is the symptom of a bug in the implementation like adding an binary object to the string.

Create some substrings to find that bug.
 
Share this answer
 

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