Calling a Method from View ASP.NET MVC -
i'm getting start asp.net mvc. i'm having below in controller class.
public actionresult test() { return view(); } public string myname() { return "chamara"; } how can print return value myname() method on test view?
in controller, modify test() action so:
public actionresult test() { viewdata["myname"] = "chamara"; return view(); } then in test.aspx view, can display name <%= viewdata["myname"] %>.
even better, dave alludes in comment, create model information want display , create strongly-typed view knows how display information.
Comments
Post a Comment