Write HTML and JQuery to via C# method -


i trying write c# class return various code pieces view in mvc4. code returning has both html , jquery in it. doing following:

output += "<table id =\"" + grid.name + "\"></table>\n"; output += "<div id=\"" + grid.pager + "\"></div>\n"; output += "jquery(\"" + grid.name + "\") //and on 

this method. output string. string contains both html , jquery. returning output:

return output; 

then, in view using @html.raw convert string:

@html.raw(mymethod.getstring()) 

the problem html elements formatted correctly jquery elements written page plain text. ideas how can page turn string actual syntax? should return string differently?

as jquery javascript, should wrap code in <script> tag:

output += "<table id =\"" + grid.name + "\"></table>\n"; output += "<div id=\"" + grid.pager + "\"></div>\n"; output += "<script type=\"text/javascript\">jquery(\"" + grid.name + "\");</script> //and on 

Comments