can't call asp-action in dialogbutton

I have a delete function in my controller. I want to call this function in my view with the dialog button. when i want to use asp-action in the tag to link the delete function this doesn't work. It's like asp-action can't be used. when i debug i never get to my function . This picture is from my dialog in my view.  

  and this is a picture of the delete function in my controller


1 Reply 1 reply marked as answer

IS Indrajith Srinivasan Syncfusion Team January 8, 2021 10:07 AM UTC

Hi Wout, 
 
Greetings from Syncfusion support, 
 
We have validated your reported query. In order to call the controller action, from the view of the dialog button. We suggest you to bind the click event, for the dialog buttons and navigate to the controller action using (@Url.Action). Check the below code blocks and sample for reference. 
 
cshtml 
 
 
<div id='container' style="height:400px;"> 
    <ejs-button id="targetButton" content="Open Dialog"></ejs-button> 
    <ejs-dialog id="dialog" header="Dialog" content="This is a Dialog with button and primary button" target="#container" width="250px"> 
        <e-dialog-buttons> 
            <e-dialog-dialogbutton buttonModel="@ViewBag.DialogButtons1" click="dlgButtonClick"></e-dialog-dialogbutton> 
        </e-dialog-buttons> 
    </ejs-dialog> 
</div> 
<script> 
    window.onload = function () { 
        document.getElementById('targetButton').onclick = function () { 
            var dialog = document.getElementById("dialog").ej2_instances[0]; 
            dialog.show(); 
        } 
    } 
    function dlgButtonClick() { 
        location.rel='nofollow' href = '@Url.Action("Delete", "Home")';      
    } 
</script> 
 
 
Controller.cs 
 
 
public async Task Delete() 
{ 
  //Your delete action 
} 
 
 
Please let us know if the solution helps, 
 
Regards, 
Indrajith 


Marked as answer
Loader.
Up arrow icon