I have a function in c # where I use StringBuilder and added JavaScript code, this is my helper:
public static string RegisterJS(this System.Web.Mvc.HtmlHelper helper, string scriptLib)
{
StringBuilder JavaScript = new StringBuilder();
JavaScript.AppendFormat(@"<script type= ""text/javascript"">{0}", Environment.NewLine);
JavaScript.AppendFormat(@"var toolbar = new toolBarObject('toolbarObj');{0}", Environment.NewLine);
JavaScript.AppendFormat(@"toolbar.disableElements('" + scriptLib + "', true);{0}", Environment.NewLine);
...
...
JavaScript.AppendFormat(@"{0}", Environment.NewLine);
return JavaScript.ToString();
}
This function is called to load an application in Asp.Net MVC4 within a section:
as follows:
@section ToolBar{
<h2>aqui debo cargar mi javascript</h2>
@Html.RegisterJS("Personal")
}
I run the program and display the page code i have this:
<script type= "text/javascript">
and I should have this:
<script type= "text/javascript">
this happens in all lines of the function
how I can solve this problem