Visual Studio .NET - How to redirect from view to second view with value and get that value in 2nd view in MVC

Asked By Arun Tej on 13-Aug-12 01:22 PM

    Hi ,

    I want to Redirect from one view to another view with value i.e i saved the details in add page and display the save information as Label in 2nd view. I have tried with "RedirectToAction" Method,it is navigating but not displaying the Text.

    In Controller,

    ModelState.AddModelError("PropertyName","User Added");
    return RedirectToAction("ViewUsers" , "Common" , ModelState);

In my ViewUsers.aspx ,

<span id="label"></span>
<%=ValidationMessageFor(exp => exp.PropertyName)%>

Here i count not get the text i have passed from Add page but when i give static message to this property it will display
like <%=ValidationMessageFor(exp => exp.PropertyName , "Test")%> .

Peter Bromberg replied to Arun Tej on 13-Aug-12 01:40 PM
Store the message in the TempData object and pick it up from there for display in the second view.
Arun Tej replied to Peter Bromberg on 19-Aug-12 10:18 PM
Thank u peter , i got the solution