Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Persistent and Temp Data in MVC

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 25
    Comment on it

    TempData is used to pass data from one view to another view.

     

    void Keep

    When we call this method within the current action then it ensures that at the end of the current request the items in the TempData were not removed.

     @model MyProject.Models.EmpModel;
    @{ 
     Layout = "demo.cshtml"; 
     ViewBag.Title = "About";
     var tempDataEmployeet = TempData["emp"] as Employee; //need typcasting 
     TempData.Keep(); // retains all strings values 
    } 
    

     

    void Keep(string key)

    Calling this will keep the data into it

     @model MyProject.Models.EmpModel;
    @{ 
     Layout = "~/Views/Shared/Layout.cshtml"; 
     ViewBag.Title = "About";
     var tempDataEmployeet = TempData["emp"] as Employee; //need typcasting 
     TempData.Keep("emp"); // retains only "emp" string values 
    } 
    
    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: