MVC @Html Extension methods

Source: Internet
Author: User

During the MVC development process, it was found that some custom methods were needed in the view, and the previous development in Webfrom was to use a static class that was used to edit many of the frequently used methods in the solution. It is now found in MVC that you can customize the extended HtmlHelper method as follows:
1. Create a new class
You can add a folder to your project named helpers, where you can add extension classes of various types. Below we add a text processing extension class, named TextHelper.cs.

Note: Change the namespace of this class to namespace SYSTEM.WEB.MVC so that the extension method can be used in the page, otherwise the extension method will not be recognized.
2. How to use
Reference in page: @Html. Dateformate (date)

MVC @Html Extension methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.