0

I have button in the layout and action for it is defined in the base controller. How can I invoke this action every time using a common js this button is clicked in individual page?

Below is a barebones of my scenario, I have a button in layout and child uses this layout. Child has is controller ChildController which inherits from BaseController. Action is defined in the base.

Is it possible to have a common js (or any other way) which routes to the same action, so that individual page doesnt need any additional code?

_Layout.cshtml has - Exit button

 <button id="exitButton">Exit</button>

ChildPage is using _Layout.cshtml

public class ControllerBase
{
 [HttpPost]
 public void Exit()
 {}
}

public class ChildController : ControllerBase {}
tereško
  • 58,060
  • 25
  • 98
  • 150
energize
  • 5
  • 5
  • When the button is clicked, do you want to invoke the Action (which would navigate to that URL and refresh the page), or simply call that Method without a page reload/navigation? – Timothy Walters Feb 04 '14 at 01:14
  • When the button is clicked there is some logic that needs to be executed and it navigates to a URL (like a home screen). – energize Feb 04 '14 at 01:18
  • Take a look at this question and see if it works for you: http://stackoverflow.com/questions/11080601/actionbutton-instead-of-actionlink – Timothy Walters Feb 04 '14 at 01:23

0 Answers0