Y2theZ
Y2theZ

Reputation: 10412

add div to page from the code behind Asp.net/C#

Hello I have a item list that shows on my asp.net page like this:

    <div class="search-result-item">

            <div class="image">
                <img src="images/1.png"/>
            </div>
            <div class="logo">
                <img src="images/logo.png"/>
            </div>
            <div class="header">
                Title
            </div>
            <div class="message">
                Message
            </div>
            <div class="keywords">
                key1 | key2 | key3
            </div>

            <div class="links">
                <a href="link.html">Go to</a>
            </div>

        </div>

This shows a predefined layout for an item on the page.

Items are generated in the code behind.

I want for each item to create a div like the one above on the page. How can I do that using the code behind?

Thanks a lot

Upvotes: 0

Views: 4251

Answers (2)

Daniel Casserly
Daniel Casserly

Reputation: 3480

Use a repeater control You create a control that basically connects to datasource and then repeats info based on the data. Very crude description sorry. Look at it on Google.

Upvotes: 1

to StackOverflow
to StackOverflow

Reputation: 124794

You create a Control and add it to your page.

There are a large range of controls, but if you want that exact markup, and don't need any server-side processing, the LiteralControl control is probably the most appropriate.

Upvotes: 5

Related Questions