Jaggu
Jaggu

Reputation: 6428

How can we call functions in asp.net mvc?

In webforms, we do things like:

<%# CallSomefunctions(Eval("CustId")) %>

This function is present in asp.cs which can format our data and return appropriate string. How can we do the same in asp.net mvc since we do not have any concept of code behind?

Upvotes: 0

Views: 228

Answers (1)

Travis Gockel
Travis Gockel

Reputation: 27623

The short answer is: You don't. Doing this violates the principles of MVC. The responsibility of your .aspx page it to convert a model (some .NET object) into something you can present to the user and nothing else. Having it execute code violates this one-responsibility principle.

Upvotes: 1

Related Questions