Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How do i add asp text boxes, buttons and button click event in MVC ?
Am new to MVC i want to know how we can add button click event in MVC.
Ex: For the scenario ,I have 4 text boxes and one submit button.On click of submit button records should be saved in DB.How to do this using MVC ?
Posted

A forum like this isn't the best place to learn something like mvc from scratch. Instead get a book on MVC and read through it, or at least look at some on-line tutorials.

http://www.asp.net/mvc[^]

I'm going to assume you come from a webforms background, and if so you have to get your head around the different paradigm of MVC. Things like click-events etc were all abstractions around http that webforms provided for you in offer to give you an event-driven framework. With MVC you're using more bare-bones http, so a rough answer to your question is that your buttons will submit a form and the action of the form will be an action on one of your controllers. That is how you react to button clicks.

As I said though, you need to spend some time understanding the basics first and then things will become clear to you. There isn't really any one-to-one relation between doing things with webforms and doing them with MVC so questions like "how do I do <webforms feature=""> in MVC" will rarely produce a straight-forward answer as you should be doing things in an MVC way and forget about how you did them with webforms.
 
Share this answer
 
Comments
Am Gayathri 17-Mar-15 9:03am    
ohh...
Thanks
asp.net MVC change the way different from asp.net, you must forget asp.net drag-drop Development mode,MVC use Controller to accept request as background, you need to know how to sumbit , the html label <form action="system/login"></form> and <input type="submit" /> do this thing
 
Share this answer
 
v3
Comments
Am Gayathri 18-Mar-15 11:30am    
thank u
 
Share this answer
 
Comments
Am Gayathri 18-Mar-15 11:30am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900