I am trying to write a C# class that will return various code pieces to a view in MVC4. The code I am returning has both html and jquery in it. Currently I am doing the following:
output += "<table id =\"" + grid.name + "\"></table>\n";
output += "<div id=\"" + grid.pager + "\"></div>\n";
output += "jQuery(\"" + grid.name + "\") //and so on
This is my method. Output is a string. This string contains both html and jquery. I am simply returning output:
return output;
Then, in my view I am using @Html.Raw to convert the string:
@Html.Raw(MyMethod.GetString())
The problem is that the html elements a formatted correctly but the jquery elements are written to the page as plain text. Any ideas how I can get the page to turn the string into actual syntax? Should I return my string differently?