I have a question about @helper on Razor. I'm trying do a @helper simple example, but i can´t obtain a result.I need add custom text to javascript code. On firebug i can see that test var is empty, i don´t understand this. This is the code:
@fillString()
@renderScript()
@helper fillString(){
test = new List<string>() ;
test.Add("Id : '1'");
test.Add("Text: 'hello world'");
}
@helper renderScript(){
<script type="text/javascript">
var count = "{ @Html.Raw(test.Count) }";
var testArray = @{ new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(test.ToArray()); };
</script>
}
Thank you very much