none
Add locations to map via C# RRS feed

  • Question

  • Hello all,

    Is it possible to call the javascript to make a map, while passing in a variable List<objecttype> of locations to put on the map from c#?


    Bits of Fury

    Sunday, April 29, 2012 8:23 PM

Answers

  • Yes it's possible, I am doing it in ASP.NET MVC, I have a list of NewsItemDto which all have a location,
    I pass this list to the view, where I serialize it to JavaScript:

    My C# Models coming into the view:

    @model IEnumerable<HLWebRole.HLServiceReference.NewsItemDto>

    Serializing to JavaScript and processing:

    var items = @(Html.JSValue(Model))

    function ProcessData(items) {

    ... put the items on the map...
    }


    To serialize from C# to JavaScript I use this:

    http://forums.asp.net/t/1758990.aspx/1?How+to+get+access+to+a+list+of+Models+in+jQuery+


    rune007

    • Marked as answer by attrib75 Tuesday, May 1, 2012 12:01 AM
    Monday, April 30, 2012 1:34 PM

All replies

  • Yes it's possible, I am doing it in ASP.NET MVC, I have a list of NewsItemDto which all have a location,
    I pass this list to the view, where I serialize it to JavaScript:

    My C# Models coming into the view:

    @model IEnumerable<HLWebRole.HLServiceReference.NewsItemDto>

    Serializing to JavaScript and processing:

    var items = @(Html.JSValue(Model))

    function ProcessData(items) {

    ... put the items on the map...
    }


    To serialize from C# to JavaScript I use this:

    http://forums.asp.net/t/1758990.aspx/1?How+to+get+access+to+a+list+of+Models+in+jQuery+


    rune007

    • Marked as answer by attrib75 Tuesday, May 1, 2012 12:01 AM
    Monday, April 30, 2012 1:34 PM
  • Thanks for the answer.  I don't think that will work as I'm using Web Forms.  This gives me somewhere to look though.

    Cheers


    Bits of Fury

    Monday, April 30, 2012 11:58 PM