Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Controller:
C#
public ActionResult ComplainPage()
       {
           if (TempData["ComplainNo"] == null)
           {
               TempData["COmplainNO"] = Guid.NewGuid().ToString();

           }
           ViewBag.CompaintNO = TempData["ComplainNo"].ToString();
           return View();
       }

       [HttpPost]
       public ActionResult ComplainPage(ComplaintModel obj)
       {
           if (ModelState.IsValid)
           {
               ComplaintIssueDetailsContext cidc = new ComplaintIssueDetailsContext();

               if (cidc.AddComplaintIssue(obj))
               {
                   ViewBag.Message = "Record added Successfully";
               }

           }
           return View();
       }

view:


Complaint Id:


@Html.EditorFor(c => c.complaintId, new { ViewBag.CompaintNO })


@Html.ValidationMessageFor(c => c.complaintId, "", new { @class = "text-danger" })



What I have tried:

i have created a controller,in that i have used tempdata to store a GUID value and used viewbag to send the data to the view

And in the view, i am assign the viewbag data to the control present in view page.

but the problem is, the viewbag data is not assigning to the control and not saving in the database, and at the same time it is not replicating on another page (i.e., this is your tracking number)
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900