Skip to main content
Removed line of code that was unrelated to the answer
Source Link
jessegavin
  • 75.8k
  • 28
  • 141
  • 165

You are mixing server side and client side code.

If you want to spit out client side code on the server you can.

But best is to serialise your model data into JSON and put it on the client.


Rough example:

Update

@{ var uploadSettingsProvider = UniversalContainer.Container.Resolve<IUploadSettingsProvider>(); var js = new JavaScriptSerializer(); } myJavascriptObject.Models = @js.Serialize(myModels); 

You are mixing server side and client side code.

If you want to spit out client side code on the server you can.

But best is to serialise your model data into JSON and put it on the client.


Rough example:

Update

@{ var uploadSettingsProvider = UniversalContainer.Container.Resolve<IUploadSettingsProvider>(); var js = new JavaScriptSerializer(); } myJavascriptObject.Models = @js.Serialize(myModels); 

You are mixing server side and client side code.

If you want to spit out client side code on the server you can.

But best is to serialise your model data into JSON and put it on the client.


Rough example:

Update

@{ var js = new JavaScriptSerializer(); } myJavascriptObject.Models = @js.Serialize(myModels); 
added 266 characters in body
Source Link
Aliostad
  • 81.9k
  • 21
  • 164
  • 209

You are mixing server side and client side code.

If you want to spit out client side code on the server you can.

But best is to serialise your model data into JSON and put it on the client.


Rough example:

Update

@{ var uploadSettingsProvider = UniversalContainer.Container.Resolve<IUploadSettingsProvider>(); var js = new JavaScriptSerializer(); } myJavascriptObject.Models = @js.Serialize(myModels); 

You are mixing server side and client side code.

If you want to spit out client side code on the server you can.

But best is to serialise your model data into JSON and put it on the client.

You are mixing server side and client side code.

If you want to spit out client side code on the server you can.

But best is to serialise your model data into JSON and put it on the client.


Rough example:

Update

@{ var uploadSettingsProvider = UniversalContainer.Container.Resolve<IUploadSettingsProvider>(); var js = new JavaScriptSerializer(); } myJavascriptObject.Models = @js.Serialize(myModels); 
Source Link
Aliostad
  • 81.9k
  • 21
  • 164
  • 209

You are mixing server side and client side code.

If you want to spit out client side code on the server you can.

But best is to serialise your model data into JSON and put it on the client.