jquery - Assigning collection object of Tuple<String,String,String> to javascript variable in .NET MVC -
i have model collection of tuple<string,string,string>
public class patientdetails { public collection <tuple<string,string,string>> fieldvalidationrules { get; set; } }
view stronglytyped i.e patientdetails accessed in cshtml @model
now want assign fieldvalidationrules object javascript variable can refer client validations per rules specified in collection. have following line of code:
$(document).ready(function(){ _jsfieldvalidationrules = "@model.fieldvalidationrules"; });
but have problem here _jsfieldvalidationrules doesn't assigned values in "@model.fieldvalidationrules instead gets assigned to:
system.collections.objectmodel.collection 1[system.tuple3[system.string,system.string,system.string]]
what do make work.
what do make work.
use json serializer:
$(document).ready(function() { _jsfieldvalidationrules = @html.raw(json.encode(model.fieldvalidationrules)); });
Comments
Post a Comment