What is different between @helper and @model in mvc 3? [Resolved]

Posted by Allemahesh under ASP.NET on 7/22/2013 | Points: 10 | Views : 1145 | Status : [Member] [MVP] | Replies : 1
What is different between @helper and @model in mvc 3?




Responses

Posted by: Jitendrasoft09 on: 7/22/2013 [Member] [MVP] Starter | Points: 50

Up
0
Down

Resolved
Nice question Allemahesh,

@model- To call the class functionalities which is written in model.
@helper- To create a method to re use the code within your view templates.

@helper TruncateString(string input, int length)

{
if (input.Length <= length) {
@input
} else {
@input.Substring(0, length)<text>...</text>
}
}


And,

@model IList<Sample.Model.Products>



To make sure you are click below link to understand more-

http://weblogs.asp.net/jgalloway/archive/2011/03/23/comparing-mvc-3-helpers-using-extension-methods-and-declarative-razor-helper.aspx



Jitendra Kumar
If my post helps you, plz mark as an answer.

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response