Courts-Tech
asked on
How do I call a function (Razor) from a button click event.
I have an InvoiceEdit.cshtml page. i have written a @function {public List<int> AddInvoiceFeeItem (List<int> feeList) { } in InvoiceEdit.cshtml. I can call the function inline in the page ( @AddInvoiceFeeItem(); ) and it works just fine.
How do i call this same function from a user initiated event like a button.click or link click ?
How do i call this same function from a user initiated event like a button.click or link click ?
Well MVC is all about actions, so you simply create a link to the controller/action and expose the functionality through an action.
@Html.ActionLink(@Person.N ame, "EditPerson", new { id = @Person.Id }
@Html.ActionLink(@Person.N
ASKER
I'm still not clear on this. My @function, named AddInvoiceFee, (residing inside the .cshtml file) returns a List<int> and it accepts a List<int> as a parameter. I am not sure how the ActionLink can call the AddInvoiceFee function (that is not part of a controller/action) and further more, how does it retrieve the return value of the function.
Like I said on my first comment, I'm fairly new to MVC and Razor.
Like I said on my first comment, I'm fairly new to MVC and Razor.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I apologize for the late response... had to set aside the project I was working on. The solution did not really addressed my question in a way that I could understand. I did mention that I am new to MVC/Razor and I was looking for more of a code example as an answer.
ASKER