1

I'm looking for the Asp.net placeholder equivalent in MVC5 using Razor.

My main problem is that I have too much logic in views/partial views, so I need some kind of placeholder in which the controller could specify the view, and model to use in that placeholder, or call another controller.

Is there the possibility?

Maybe I'm talking about impossible/stupid/nonsense things or something, but I'm new to MVC and I'm currently migrating from WebForms... So sorry for the inconvenience

Edit 1:

I'm searching for more or less server control in what is renderized in the view, providing a shortcut to writing out raw HTML elements that are frequently used (common Controls), like in WebForms.

piraces
  • 1,320
  • 2
  • 18
  • 42
  • are you looking for [this](http://stackoverflow.com/questions/22105833/how-do-i-add-placeholder-text-from-the-model-into-a-mvc-view)? – Polynomial Proton Mar 15 '17 at 16:51
  • @TheUknown no... it's not a text placeholder... is this type of placeholder: https://msdn.microsoft.com/es-es/library/3h1c92ts(v=vs.80).aspx – piraces Mar 15 '17 at 16:53
  • I think rendering sections and layouts are the closest. Check [this](https://weblogs.asp.net/scottgu/asp-net-mvc-3-layouts-and-sections-with-razor) and [this](http://stackoverflow.com/questions/4163429/contentplaceholder-in-razor). – Polynomial Proton Mar 15 '17 at 17:02
  • @TheUknown thank you very much! I think is more or less the approach to my problem.. put this as a question if you want and i will put the check ;) – piraces Mar 15 '17 at 17:09
  • Yeah no worries. Good luck! – Polynomial Proton Mar 15 '17 at 17:10
  • 1
    @TheUknown while I was coding my solition I realized that the best solution it's to create an "Html Helper" that basically allow to create own custom helpers to encapsulate complex HTML markup – piraces Mar 16 '17 at 08:10

1 Answers1

2

The solution for me was not the @RenderSection functionality. What I expected is what Html Helpers provide for MVC.

MVC’s HTML helpers simply provide a shortcut to writing out raw HTML elements that are frequently used.

I found the solution in this journal: Html Helpers.

In MVC development, HTML helpers replace the server control, but the similarities aren’t exactly parallel.

This was what I was looking for... a way to give server control to MVC.

I post this answer because maybe it helps others with the same problem (it was the solution for me).

piraces
  • 1,320
  • 2
  • 18
  • 42