No announcement yet.

Instantiate an object from javascript to call a method....

  • Filter
  • Time
  • Show
Clear All
new posts

    Instantiate an object from javascript to call a method....

    • Bridge.NET 17.7.0
    • I have TripSeekerSearch.Engine project which is a Bridge.NET project and a class SearchInput
    Click image for larger version

Name:	1.png
Views:	1
Size:	38.7 KB
ID:	6085

    I am trying to instantiate the SearchInput class from within JS as I have a method Search():
     public class TripSearchEngine {     public static SearchOutput Search(SearchInput aSearchParameters)     {         var searchEngine = new SearchEngine(Trips());          return searchEngine.Search(aSearchParameters);     } }
    that takes a parameter of that type with the following:
     var seachInput = new TripSeekerSearch.Engine.Framework.Search.Dtos.SearchInput();
    but am getting undefined:
    Click image for larger version

Name:	2.png
Views:	1
Size:	10.6 KB
ID:	6086
    The namespace is correct and I have had a look at indicates that this should be easily possible.

    What have I missed? How do I make this work?

    Your code looks correct. By changing the namespace of your sample, I was able to call the full classpath.

    In the screen capture of Chome dev tools that you provided, your js call did not fail, it just did not write anything to the console. What you see is the default functionality of Chrome dev tools and is the expected result.

    In the browser developer tools, on the next line after declaring var seachInput, add console.log(seachInput) to output the object you defined above to the console. The following should work:

    var test = new TripSeekerSearch.Engine.Framework.Search.Dtos.SearchInput();
    Hope this helps.


      Doh!!! Thanks geoffrey.mcgill. It did work exactly as you described. I was too hasty with the undefined.