@Html.LabelFor(model => model.FirstName)
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more
Asp Net Mvc Error Page
about Stack Overflow the company Business Learn more about hiring developers or posting ads
Asp Net Mvc Error Cshtml
with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack asp net mvc error handling Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MVC 4-Return error message from Controller -Show in View up vote 15 http://techfunda.com/howto/259/passing-error-to-view-from-controller-action down vote favorite 4 I doing a C# project using Razor in VS2010.(MVC 4). I need to Return error message from Controller to View and show it to User. What i was tried is: CONTROLLER: [HttpPost] public ActionResult form_edit(FormModels model) { model.error_msg = model.update_content(model); ModelState.AddModelError("error", "adfdghdghgdhgdhdgda"); ViewBag.error = TempData["error"]; return RedirectToAction("Form_edit", "Form"); } VIEW: @model mvc_cs.Models.FormModels @using ctrlr = mvc_cs.Controllers.FormController @using (Html.BeginForm("form_edit", "Form", FormMethod.Post)) {
} Please help me to achieve this. asp.net-mvc-4 razor share|improve this question edited Nov 22 '13 at 9:20 Dominic Zukiewicz 4,73842651 asked Nov 22 '13 at 9:18 Ramesh 1261111 are you sure that want return redirect and not view? –Grundy Nov 22 '13 at 11:35 try return View(model) instead of return RedirectToAction("Form_edit", "Form"); –Grundy Nov 22 '13 at 11:41 Ya, I need return RedirectToAction("Form_edit", "Form"); –Ramesh Nov 25 '13 at 5:26 return view throws me a error while filling the drop down!!!! –Ramesh Nov 25 '13 at 5:27 after redirecting you will lose all data in ViewBag and etc. –Grundy Nov 25 '13 at 5:35 | show 2 more comments 3 Answers 3 active oldest votes up vote 20 down vote The Return View(model) returns you error because you don't fill the model with the values in your post method and the model data for the dropdown is empty. Please provide the Get method to explain further how to manage displaying the error. In
Websites Community Support ASP.NET Community Standup ForumsHelp Web Forms:Guidance Videos Samples Forum Books Open Source Older https://www.asp.net/hosting/tutorials/displaying-a-custom-error-page-cs Versions - Getting Started Getting StartedGetting Started with ASP.NET 4.5 Web Forms and Visual Studio 20131. Getting Started with Web Forms and Visual Studio2. Create the Project3. Create the Data Access Layer4. UI and Navigation5. Display Data Items and Details6. Shopping Cart7. Checkout and Payment with PayPal8. Membership and Administration9. asp net URL Routing10. ASP.NET Error HandlingIntroduction to ASP.NET Web FormsCreating a Basic Web Forms Page in Visual Studio 2013Creating ASP.NET Web Projects in Visual Studio 2013Code Editing ASP.NET Web Forms in Visual Studio 2013ASP.NET Scaffolding in Visual Studio 2013ASP.NET Web Forms (dotnetConf 2014)Using Page Inspector for Visual Studio 2012 in ASP.NET Web asp net mvc FormsVisual Studio 2012 Hands On LabsWhat's New in ASP.NET and Web Development in Visual Studio 2012What's New in Web Forms in ASP.NET 4.5Using Page Inspector in Visual Studio 2012Monitoring and TelemetryRoutingASP.NET 4 - RoutingASP.NET 4 - Defining RoutesASP.NET 4 - Constructing URLs from RoutesASP.NET 4 - Accessing URL Parameters in a PageJavaScript and Client FrameworksASP.NET 4 - Microsoft Ajax OverviewASP.NET AJAX Control Toolkit (maintained by DevExpress)Working with Data Getting Started with ASP.NET 4.5 Web FormsModel Binding and Web Forms in Visual Studio 20131. Retrieving and Displaying Data2. Updating, Deleting, and Creating Data3. Sorting, Paging, and Filtering Data4. Integrating JQuery UI Datepicker5. Using Query String Values to Filter Data6. Adding Business Logic LayerASP.NET 4 Web Forms - Validating User Input in a PageASP.NET 4 Web Forms - State ManagementASP.NET Data Access - Recommended ResourcesServer Data ControlsASP.NET 4 Data-Bound ControlsASP.NET 4 Data Source Controls OverviewASP.NET 4.5 Chart ControlRecommended Resources for ASP.NET Data AccessSe