Question: When ever i execute the program the output says not a palindrome when it is a palindrome(only does this when input has spaces or punctuation) can some one tell me where i went wrong in my code? 

```
public class Palindromes
{

 public static void main(String[]args)

 {

     ConsoleIO keyboard=new ConsoleIO();

     String word, word2="",terminate;

     int length;

     do

     {

     System.out.print("Enter a string:"); 

         word=keyboard.readLine();

         word=word.toLowerCase();

         word=word.trim();             

         word=word.replaceAll("\\W", "");

         word=word.replaceAll(" ","");

         length=word.length();

         //finding the reverse of the string          

         for(int i=length-1;i>=0;i--)

         {

         word2+=word.charAt(i);

         }

         //checking to see if the string is a palindrome

         if(word.length()==1)

         {

             System.out.println("The string you entered is not a palindrome");

         }

         else if(word.equals(word2))

         {

             System.out.println("The string you entered is a palindrome.");

         } 

         else

         {

             System.out.println("The string you entered is not a palindrome.");

         }

         System.out.print("Do you want to continue (yes or no):");

         terminate=keyboard.readLine();

         System.out.println();

     }

     while(terminate.equalsIgnoreCase("yes"));

 }
}

```

Answer: 
I would consider not using partial views at all, for the reasons that you mentioned. Instead of loading partial views with ajax, load json data from controller. Use JavaScript template like handlebars.js to get the razor effect on the client side.
Much cleaner. Smaller http payload.
I had a similar situation using JQGrid. I ended up with JavaScript up the wazoo on any view that used the grid. My solution was to put any of the heavy-lifting javascript into external files, and namespace them like this:

```
var JqGridHelper = JqGridHelper || {};
JqGridHelper.SetupGrid = function (gridTable, pager, gridJson, colNameJson, colModelJson, label, rowNum, gridCompleteFunc, columnChooser) {
    gridTable.jqGrid({
        datatype: "local",
        data: gridJson,
        colNames: colNameJson,
        colModel: colModelJson,
        rowNum: rowNum,
        autowidth: true,
        height: '100%',
        pager: pager,
        sortname: 'id',
        viewrecords: true,
        sortorder: "desc",
        caption: label,
        gridComplete: gridCompleteFunc
    });

    gridTable.jqGrid('navGrid', pager, { edit: false, add: false, del: false });
    if (columnChooser == true) {
        JqGridHelper.AddColumnChooser(gridTable, pager, function() {

        });
    }

};

```

Try to abstract as much of the reusable DataTable binding and initialization code, then just call your abstracted methods from the JavaScript on the partial views.

If you go the way of external javascript files, be sure that you're loading them at the appropriate time, rather than loading them all on the initial page-load.