@functions { int AddTEST(int a, int b) { return a + b; } }
Then I tried calling the function in index.cshtml like so-
@AddTEST(1,2);
As I thought, if failed. So, just to keep in mind all you scripters that RenderPage() in WebMatrix is not quiet like include files in PHP or Classic ASP. For functionality that is shared across pages you will need to create a class for that, which is pretty easy to do, but not quiet what you might be used to. Welcome to OOP :)
3 comments:
Not really, you just forgot to put "public static" in front of "int add."
I just did this function in webmatrix, worked a treat, then i made a GetValue DB function, pass in fieldname, tablename, whereclause, awesome reuse.
Also, forgot to say, need to put this code into App_Code folder.
Patrick
CoffeeRunnr.com
Late response, but thanks for the info.
Post a Comment