Amrit
Amrit

Reputation: 903

Creating a div element on the server side using C#

I am trying to create divs dynamically in a view page of an asp.net mvc project. This is the pseudo code:

<%
        foreach (element in Model)
        {
           create the html div element with Div.id = Model.id 
        }
    %>

I looked in the system.web.mvc.htmlhelper object. It provides support for a lot of html elements but not a div. Any Hints ?

Upvotes: 0

Views: 910

Answers (1)

ajay_whiz
ajay_whiz

Reputation: 17931

There is no such helper for div. But, you can create your own HTML helper for it.

or simply you can go ahead and create divs in view page as

<%
        foreach (element in Model)
        {
           %>
          <div id="<%:element.id%>">
                .. some html..
           </div>     
      <%}
    %>

Upvotes: 1

Related Questions