views:

35

answers:

1

I have two views

1 . Add.aspx 2. Change.aspx

View Add has a TextBox named menu, where i can type data. I have a 'Add' button below the textbox which redirects to the next view 'Change' 'Change' view has a button named 'Cancel' which on click redirects back to the add page.

My Question is,

How can I persist data entered in the 'Menu' Textbox when I click 'Cancel' from the 'Change' View. Currently it gets cleared. Should I save it in a session ? or is there any other alternative ?

+2  A: 

If you're doing an actual redirect, you can use TempData to store data inbetween views, e.g.:

TempData["YourData"] = TextBoxText;

See Passing Data in an ASP.NET MVC Application on MSDN.

Tchami