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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -