Skip to content
Loading
  • Marius Vasile
    +1
    I managed to get the id with ajax but not to redirect the page. Anyway, it fits my needs for the moment. Code below
     
    1. $(function () {  
    2.     $('#btnPost').on('click', function () {  
    3.         var id = $("#fun").val();  
    4.         $.ajax({  
    5.             type: 'POST',  
    6.             url: '/WO/Reports?handler=Test&idPost=' + id,  
    7.             beforeSend: function (xhr) {  
    8.                 xhr.setRequestHeader("XSRF-TOKEN",  
    9.                     $('input:hidden[name="__RequestVerificationToken"]').val());  
    10.             },  
    11.             contentType: "application/json",  
    12.             dataType: "json",  
    13.             success: function (response) {  
    14.   
    15.             },  
    16.             failure: function (response) {  
    17.                 alert(response);  
    18.             }  
    19.         });  
    20.     });  
    21. });  
     
    +1
  • Marius Vasile
    +1
    I figured out how to pass parameter from jquery and perform a redirect as well. It is so simple actually
     
    1. "submit" asp-page-handler="Test">Button  
    1. "id" id="AssetID" />  
    1. public IActionResult OnPostTest(string id)  
    2.         {  
    3.             return RedirectToPage("/WO/Reports", new {id=id });  
    4.         }  
    where id=AssetID is populated by the jquery and name="id" is passing the value as parameter to OnPost 
    +1