Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple ITemplate placeholders equivalent in ASP.Net MVC
    primarykey
    data
    text
    <p>I am new to ASP.Net MVC and have always been using Web Forms till now. I have found <a href="https://stackoverflow.com/questions/2231501/replacement-for-itemplate-in-mvc">Replacement for ITemplate in MVC?</a> which gives an example of creating an HTML helper named BeginBlock which wraps the title &amp; content from:</p> <pre><code>@using (Html.BeginBlock("MY TITLE")) { MY CONTENT GOES HERE } </code></pre> <p>to</p> <pre><code>&lt;div&gt; &lt;div&gt;&lt;h1&gt;MY TITLE&lt;/h1&gt;&lt;/div&gt; &lt;/div&gt; MY CONTENT GOES HERE </code></pre> <p>I have a scenario where in Web Forms, we used to use multiple ITemplates to define containers within user controls which we then wrapped inside HTML, for example, in Web Forms, we could create a user control named Panel and have two ITemplate properties, one named Content and the other named ContentNonScrollable. We would then use the user control by using the following markup:</p> <pre><code>&lt;MySite:Panel&gt; &lt;Content&gt; Content 1 Goes Here &lt;/Content&gt; &lt;ContentNonScrollable&gt; Content 2 goes here &lt;/ContentNonScrollable&gt; &lt;/MySite:Panel&gt; </code></pre> <p>The user control would then output the following, HTML:</p> <pre><code>&lt;div class="my-panel"&gt; &lt;div class="my-panel-content"&gt; Content 1 Goes Here &lt;/div&gt; &lt;div class="my-scrollable-panel-content"&gt; Content 2 Goes Here &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Is there any way in MVC, where through HTML Helpers (or anything else), we can devise something equivalent to the above Web Forms example through markup within the .cshtml template file?</p> <p>For example something like (obviously, the below doesn't have correct syntax, just to explain what we have in mind):</p> <pre><code>@using (Html.BeginPanel() { { Content 1 Goes Here } { Content 2 Goes Here } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload