如何在Mvc中添加Asp文本框,按钮和按钮单击事件? [英] How Do I Add Asp Text Boxes, Buttons And Button Click Event In Mvc ?

查看:81
本文介绍了如何在Mvc中添加Asp文本框,按钮和按钮单击事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在MVC中添加asp文本框,按钮和按钮单击事件?

MVC新手我想知道如何在MVC中添加按钮点击事件。

例如:对于场景,我有4个文本框和一个提交按钮。单击提交按钮记录应保存在DB中。如何使用MVC执行此操作?

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 ?

推荐答案

像这样的论坛不是从头开始学习像mvc这样的东西的最佳地方。而是获取一本关于MVC的书并阅读它,或者至少查看一些在线教程。



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



我会假设你来自webforms背景,如果是这样的话,你必须了解不同的范例MVC。诸如点击事件等所有内容都是围绕http的抽象,webforms为您提供了一个事件驱动框架。使用MVC你会使用更多的基本http,所以对你的问题的粗略回答是你的按钮将提交一个表单,表单的动作将是你的一个控制器上的动作。这就是你对按钮点击的反应。



正如我所说,你需要花一些时间先了解基础知识然后事情会变得清晰。在使用网络表单和使用MVC进行操作之间并没有真正的任何一对一关系,因此诸如我怎么做< webforms feature =>在MVC中之类的问题很少会产生直截了当的答案因为你应该以MVC方式做事而忘记你是如何用webforms做的。
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.


asp.net MVC改变了与asp.net不同的方式,你必须忘记asp.net拖放开发模式,MVC使用Controller接受请求作为后台,你需要知道如何汇总,html标签< form action =system / login>< / form>和< input type =submit/>做这件事
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


你可以在Google上搜索,有很多tutorals:

按钮事件:

http://stackoverflow.com/questions/4722935/button-event-in-asp-net-mvc [ ^ ]

点击按钮:

http://stackoverflow.com/questions/13582340/how-to-handle-the-click-button-event-in-mvc [ ^ ]
U can search on Google,there are a lot tutorals:
button event:
http://stackoverflow.com/questions/4722935/button-event-in-asp-net-mvc[^]
click button:
http://stackoverflow.com/questions/13582340/how-to-handle-the-click-button-event-in-mvc[^]


这篇关于如何在Mvc中添加Asp文本框,按钮和按钮单击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆