I\'d like to use string constants on both sides, in C# on server and in Javascript on client. I encapsulate my constants in C# class
namespace MyModel
{
You can use an HTML helper to output the script necessary, and use reflection to grab the fields and their values so it will automatically update.
public static HtmlString GetConstants(this HtmlHelper helper)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.AppendLine("");
return new HtmlString(sb.ToString());
}