Results 1 to 2 of 2

Thread: mvc simple button event

  1. #1

    Thread Starter
    Banned
    Join Date
    Aug 2016
    Posts
    62

    mvc simple button event

    I added a button to the view of the contents controller, now how do I write c# code to said button's click event ?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: mvc simple button event

    You don't. MVC does not work like Web Forms, which is the whole point. Web Forms was created to simulate Windows Forms as much as possible, so a Button has a Click event that you handle in your server-side code much as you would handle the Click event of a Button in Windows Forms. MVC works on a very different paradigm.

    I think you probably need to do some reading on how MVC actually works but, in general, you can either submit a form using your button, in which case you'll be posting to a controller action, or you can write some JavaScript code to react to the onclick event of the button on the client side.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width