You must Sign In to post a response.
  • Category: ASP.Net MVC

    What is helper method in mvc

    any one can explain me what exactly helper method in mvc????
  • #765151
    With MVC, HTML helpers are much like traditional ASP.NET Web Form controls.
    Just like web form controls in ASP.NET, HTML helpers are used to modify HTML. But HTML helpers are more lightweight. Unlike Web Form controls, an HTML helper does not have an event model and a view state.
    In most cases, an HTML helper is just a method that returns a string.
    With MVC, you can create your own helpers, or use the built in HTML helpers.
    HTML helper methods are used help to build our html controls
    see list of help helper methods list on below link

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #765156
    To perform complex tasks a helper method is used which includes code and markup.
    If you want to perform perticular common tasks on different-different pages in your website, you can use a helper.
    Though there are multiple pre-defined helpers present in ASP.NET, you can create your own custom helper too.
    A helper enables you to use a common block of code across multiple pages. Lets take an example, suppose you want to create a title item that's placed on upper portion of your website and is must be visible from every page. You can create a <div> element with some <Label> that you want to show as a title with proper styling. Instead of adding this same markup/code in each page, you can create a helper and put the markup/code in it. You can then display the title with a single line of code on any page you need.
    Makes code simpler, easier to read and maintain because if you need to change the title contents, you have to change the code only at single place.

    You can go through this URL for more details:

    Hope it helps.
    Shashikant Gurav

Sign In to post your comments