Using the Helper in a Page
- In the root folder, create a new blank file called TestHelper.cshtml.
- Add the following code to the file:
<head> <title>Test Helpers Page</title> </head> <body> <p>This is some opening paragraph text.</p> <!-- Insert the call to your note helper here. --> @MyHelpers.MakeNote("My test note content.") <p>This is some following text.</p> </body> </html>
To call the helper you created, use
@followed by the file name where the helper is, a dot, and then the helper name. (If you had multiple folders in the App_Code folder, you could use the syntax
@FolderName.FileName.HelperNameto call your helper within any nested folder level). The text that you add in quotation marks within the parentheses is the text that the helper will display as part of the note in the web page.
- Save the page and run it in a browser. The helper generates the note item right where you called the helper: between the two paragraphs.