views:

36

answers:

1

Is it really efficient to render HTML in cs file . i am talking about the efficiency only? Html helper approach in the mvc is the samething or not? rendering html in the cs file

+1  A: 

You mean that you are generating the HTML inside the CS files (model, controller, etc...) and then passing it to the view, or outputting it directly via Response.Write?

If so, I don't think there are much concerns about efficiency, apart from the fact that you are sure that everything needs to be put in memory first (the server cannot output it directly). Remember to use a StringBuilder, and not just concatenating strings.

So, it's not for efficiency reasons, you should avoid this. If you are doing this, you either have very, very specific needs, or your approach to the MVC is incorrect, and you should really review it, because this is something you should NOT be doing, as you are just throwing away all the MVC pattern and advantages...

Palantir
in asp.net webforms you would support this approach?
mazhar kaunain baig
ok so it also goes like using rendering string builder will not slow down the application?
mazhar kaunain baig
html helper is the same approach?
mazhar kaunain baig
html helper is a very good exception to what I wrote :) But html helpers should ideally produce small snippets of html code, with the intent of saving some time and coding errors when doing repetitive tasks, which are reusable across the entire application. You should use partial views to accomplish all the other tasks, which require more intensive HTML coding.
Palantir
ok thanks it was a great help really
mazhar kaunain baig
but last thing i am tempted to ask what approach will you use in asp.net webforms to render some html in a 3 tier architecture there also with appcode conding the business logic and dal
mazhar kaunain baig