How to invoke server side method

I have been trying to invoke a server side method.

I have a button and want that button to do calculations. I created a method in the custom method controller. It is just a code stub at the moment. I then attached code to the button click event. The method is called Calculate

The Button is setup to execute code on the click event. Not understanding javascript I simply copied the code from the example: return (this).Calculate(event.text);

I can accept the code is wrong. However, I cannot get the click event to fire. I run the app, click the button and nothing happens. No errors, etc. I tried trapping the event in Visual Studio by setting a break point on the method in the CustomMethodController.

Any suggestions why the Calculate button is not firing a Click event or how to trap it if it is?

Thanks,

John W

Are you following this tutorial? If yes can you paste here your code (or attach screenshots from it)? We need the event handler definition in Radzen, the TypeScript code in your angular component and finally the implementation of the server-side method.

That is what used pull I went through the source code. At this point I am simply trying to get the event to fire and then hit the method in the controller. It really does not do anything at this point. I am just trying to get from the client to the server. I think if I can get this worked out I set about the next phase of having the method do something.

I am sorry this is all so basic but I have looked at a number of resources on the web and none have been helpful at this point. So I decided to ask here.

Here is my simple controller code. (VB)

Imports System.Collections.Generic
Imports Microsoft.AspNetCore.Mvc

Namespace Solomon2020.Controllers
Public Class MyObject
Public Property Name As String
End Class

<Route("api/[controller]/[action]")>
Public Class CustomMethodController
    Inherits Controller

    Public Function Calculate(ByVal type As String) As IActionResult
        Dim list = New List(Of MyObject)()

        For i = 0 To 10 - 1
            list.Add(New MyObject() With {
                  .Name = String.Format("{0}{1}", type, i)
            })
        Next

        Return Json(list)
    End Function
End Class

End Namespace

Here is the code form the component/ts:

import { Component, Injector } from '@angular/core';
import { SolomonCostGenerated } from './solomon-cost-generated.component';
import { HttpParams, HttpClient } from '@angular/common/http';
import { environment } from '../../environments/environment';

@Component({
selector: 'page-solomon-cost',
templateUrl: './solomon-cost.component.html'
})
export class SolomonCostComponent extends SolomonCostGenerated {
constructor(injector: Injector,private http: HttpClient) {
super(injector);
}
Calculate(type: string) {
// Extract the server URL
const url = environment.solomon2020.replace(/odata./,'')// environment.sample.replace(/odata./, '');

    return this.http
        // Request the Calculate action method
        .get(`${url}api/custommethod/Calculate`, {
            // Pass the type parameter
            params: new HttpParams().set('type', type)
        })
        .toPromise();
}

}

This code looks correct. Can you zip your project and send it to info@radzen.com so we can take a closer look? There is probably some runtime error at the moment.