c# - In the View of .net MVC , the "ModelObject Attributes" value is shown as null after a PostBack -
in asp.net mvc ,i want return modelobject view after postback from[httppost]actionmethod, condtion modelobject should same/sametype of modelobject-argument used in same [httppost]actionmethod.
issue :after post null modelobjectattributes shown in same view.
otherfindings:while removing modelobject argument of [httppost]actionmethod , after postbacking ,the values shown in view
code attached.
public actionresult index() { //testmodelclass objmodel = new testmodelclass(); objmodel.name = "i get"; objmodel.message = "get message delivered"; return view(objmodel); }
issue : action method not working.ie; "no values shown @ view" otherfindings :values shown in view, while not using "testmodelclass objmodel" argument.
[httppost] [actionname("index")] public actionresult indexpost(testmodelclass objmodel) { enter code heretestmodelclass objmodel1 = new testmodelclass(); objmodel1.name = "i post"; objmodel1.message = "post message delivered"; return view("index",objmodel1); }
model
public class testmodelclass { public string name { get; set; } public string message { get; set; } }
view
@model testapp.models.testmodelclass @using (html.beginform("index","home")) { <table> <tr> **@html.textboxfor(x=>x.name)** </tr> <tr> **@html.textboxfor(x=>x.message)** </tr> <tr> <input type="submit"name="submit",value="enter"> </tr> </table> }
kindly check issue , inform other valid solutions available. in advance
Comments
Post a Comment