简体   繁体   中英

how to call c# function in razor page with out redirect page

this goal page

as in the link above I want to see the sub-object of the tree on the web, so if I press the ▶ button, I want to search the DB through efcore.

To solve this, I thought about how to execute a specific function in cshtml, but I realized that the problem is that even if the function is executed, there is no change in the view. Whenever the ▶ button to view sub-items in the tree is clicked, I want to search for sub-items in the DB and update the view without page redirection.

I tried using the redirect method. it is not comfortable

cshtml

@if (Model.authority)
    {content }

cshtml.cs

public IActionResult OnPostChagneMainCategorySelect()
{
     return RedirectToPage("/MyPage/Leader", new
     {
         _selectionWorkState= workState,
         _selectionItem = searchingItems,
         _selectionMain = searchingCategorys,
     });
}

If you want to return the same page you are on you can use

return Page();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM