hi: Anyone how can i handle server side button event in MVC view ? or set session or pro开发者_StackOverflow中文版file variables ?
There are no server side buttons and events in ASP.NET MVC. There are Models, Controllers and Views. Views usually contain standard HTML markup such as links and anchors and HTML forms that could post back to a controller and the lifecycle repeats: a controller receives a request, it queries a repository to fetch a model, maps this model to a view model and passes the view model to the view.
The following web site is a good place to start with ASP.NET MVC: http://www.asp.net/mvc
As Darin mentioned, there aren't server side buttons in ASP.NET MVC. Actually to be totally honest, you can make them work, but they will not do what you are expecting.
If you want to have a button call back to the server, you'll need to use: AJAX and then return the ActionResult you want. This question should help - ASP.NET MVC controller actions that return JSON or partial html.
One question you'll need to figure out is if you want to use the Microsoft AJAX library or jQuery. If you are used to ASP.NET, I would first look at the Microsoft one. A quick search should give you a bunch of resources.
Erick
精彩评论