.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

How to use [HttpPost]

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :ASP.Net
Hello, i am looking through the MVC turotial : http://www.asp.net/mvc/tutorials/getting-started-with-mvc-part6   I am wondering how to use this code:[HttpPost] public ActionResult Create(Movie newMovie) { if (ModelState.IsValid) { db.AddToMovie(newMovie); db.SaveChanges(); return RedirectToAction("Index"); } else { return View(newMovie); } } I release, the [HttpPost] is saying use this actionResult on a post. However i am using .net 3.5 and can not get [HttpPost] to be recognized by the compiler. im not sure if i am just missing a "Using" statement or wether this is only supported in .net 4.0. If it is only supported in 4.0, how do i do this in 3.5   Thanks, -Mike 

View Complete Post

More Related Resource Links

Updating ViewModel values on HttpPost

Hi there, I am just getting started with MVC after many years of WebForms development. I am struggling with some basics that I hope you can help out with. I have a very simple page with two textbox fields, one called Input where a user will enter something, and one called Output where I want to return some string after they post the form, much like a postback scenario in WebForms. I have the View connected to a ViewModel for strong typing. The ViewModel: public class TestViewModel { public string Input { get; set; } public string Output { get; set; } } The View: <% Html.BeginForm(); %> <%: Html.TextBoxFor(x => x.Input) %> <input type="submit" value="Submit" /> <br /><br /> <%: Html.TextAreaFor(x => x.Output)%> <% Html.EndForm(); %>   The Controller: public ActionResult Test() { var viewModel = new TestViewModel(); viewModel.Input = "Enter something"; return View("Test",viewModel); } [HttpPost] public ActionResult Test(TestViewModel viewModel) { viewModel.Output = "Here is some response"; return View("Test", viewModel); } The problem I have is that the

using grid in MVC and use HTTPPOST

Hi, I want to use a grid in asp.net MVC application. I did an evaluation and found JQgrid to be optimum from performance point of view(minimum posback). What is your views about this and suggest if you have any other grid in mind which performs better and which is free of cost for commercial usage. Also now a want to post data from edited grid back to server from Jquery base JQgrid .Should i do it using httpget or httppost. If i use HTTPPOST, what should i calculate in controller and what in model As per examples available on net, people are putting calculation logic in controller(See article http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx) I need to know whether it is good practice to put business logic in controller rather than restricting it for routing to view and model. Controller code as given in mentioned website is having following codepublic ActionResult DynamicGridData (string sidx, string sord, int page, int rows) { var context = new HaackOverflowDataContext(); int pageIndex = Convert.ToInt32(page) - 1; int pageSize = rows; int totalRecords = context.Questions.Count(); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize); var questions = context.Questions .OrderBy(sidx + " " + sord) .Skip(pageIndex * pageSize) .Take(pageSize); var jsonData = new { total = totalPages,

httppost action result for masterpage


hi guys,

I have a search section inside my master page and the section is a partical view (user control) actually. here it is;

<% Html.RenderPartial("SearchUserControl"); %>

I am wondering that how I can assign a httppost to the button on this partial view ? it needs to work on  every page.

thanks !

httppost for multiple buttons


hi guys;

in my mvc 2.0 app, I have a controller which will have 2 httppost actionresult.

I am wondering that how I could handle them in my view page. thanks !

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend