asp.net mvc - ASP MVC4: A issue when manipulating variable value in controller -
thanks everyone's effort of helping me out, i'm facing problem in controller below, make simple , easy:
controller c{ public list<model> a; //used in action a, if it's searched list, don't initialize; public bool searched = false; public actionresult a(){ if(searched){ viewbag.a = a; }else //initial list = db.model.where(); ..... return view() } //return result list when people search keywords public actionresult b(string str){ = db.model.where(d=> d.id = str); search = true; } }
but, turned out value of both , researched never changed after b called
did miss critical knowledge in .net mvc?
any related articles welcomed
thanks
you should use tempdata
keep value after redirect. tempdata designed for. in example be:
controller c{ public actionresult a(){ tempdata["str"] = "this a"; return redirecttoactionb() } public actionresult b(){ tempdata["str"] += "this b"; return view() } }
Comments
Post a Comment