c# - How to return updated partial View along with its parent View (postback) -
i have parent view 2 partial views inside it, partial views contains few textbox , button, when submit button, partial views show message. code below :
view :
<%@ page title="" language="c#" masterpagefile="~/views/shared/site.master" inherits="system.web.mvc.viewpage(of test.parentmodels)" %> <% html.renderpartial("login", model.loginmodel)%> <% html.renderpartial("register", model.registermodel)%>
model :
public class loginmodel { //code here } public class registermodel { //code here } public class parentmodel { public loginmodel loginmodel {get; set;} public registermodel registermodel {get; set;} }
controller :
//login page call method on submit public login(loginmodel model) { //do changed login html view return view("login", model); }
the problem don't know how return updated partial view along parent (postback) , don't want use ajax achieve this. tried both return view("login", model) , return partialview("login", model), both shows partial view without parent. appreciated , sorry bad english.
since want full page postback, though postback partialview part, in corresponding action method need return main view(which has 2 partials in case) , also capture whatever state required postback , set model object ( if need persist state) expected main view.
e.g.
return view("parentviewname",objparentmodel);
Comments
Post a Comment