Display Error Messages In Asp.net Mvc
Contents |
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick
Aspnet Mvc Nuget
answersQ&A Ask a Question View Unanswered Questions View All Questions... C# questions aspnet mvc source Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business
Aspnet Mvc Tutorial
Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools aspnet mvc 5 Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most aspnet mvc 4 Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ How to Display a error message in view from controller,MVC 4? Rate this: Please Sign up or sign in to vote. See more: MVC Hi.. I am new to MVC 4. I am developing a simple application in MVC 4 using Razor in c#. Now i need to Display a error in view which is pass from controller? How can i achieve it? MY CODES: MY VIEW CODE: ------------- @model mvc_cs.Models.FormModels @using ctrlr = mvc_cs.Controllers.FormController @{ ViewBag.Title = "form_edit"; Layout = "~/Views/Shared/_Layout.cshtml"; }
form_edit
MY CONTROLLER: -------------- [HttpPost] public ActionResult form_edit(FormModels model) { model.error_msg = model.update_content(model); TempData["error"] = "fjghsfhgflsh"; ModelState.AddModelError("error.error", "adfdghdghgdhgdhdgda"); return RedirectToAction("Form_edit", "Form",model.error_msg); } Posted 7here for a quick overview of the site Help Center Detailed answers to any
Aspnet Mvc Cms
questions you might have Meta Discuss the workings and policies aspnet mvc 6 of this site About Us Learn more about Stack Overflow the company Business Learn more about
Aspnet Mvc 3
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow http://www.codeproject.com/Questions/679815/How-to-Display-a-error-message-in-view-from-contro 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 down vote favorite 4 I doing a C# project using Razor in VS2010.(MVC 4). I need to Return http://stackoverflow.com/questions/20141102/mvc-4-return-error-message-from-controller-show-in-view 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)) {
@Html.ValidationSummary("error") @Html.ValidationMessage("error") |
@Html.DisplayNameFor(model => model.content_name) @Html.DropDownListFor(x => x.selectedvalue, new SelectList(Model.Countries, Model.dd_value, Model.dd_text), "-- Select Product--") |
---|
Server Dashboard eXpressApp Framework CodeRush Cross-Platform Core Libraries Tools and Utilities End-User Documentation Loading…