简体   繁体   English

从Asp.net/C#后面的代码向页面添加div

[英]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: 您好,我有一个项目列表显示在我的asp.net页面上,如下所示:

    <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. 我想要为每个项目创建一个div,就像页面上的上面一样。 How can I do that using the code behind? 如何使用背后的代码做到这一点?

Thanks a lot 非常感谢

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. 控件种类繁多,但是如果您想要精确的标记,并且不需要任何服务器端处理,则LiteralControl控件可能是最合适的。

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. 在Google上查看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 c#从asp.net页面访问背后的代码 - c# Code behind access from asp.net page ASP.NET C#从Code Behind设置OnSelectedIndexChanged - ASP.NET C# Set OnSelectedIndexChanged from Code Behind 使用JavaScript从页面加载背后的代码中添加css类加载asp.net C# - adding css class from code behind on page load asp.net C# using javascript 使用asp.net C#从后面的代码添加,更新和删除数据库数据 - add, update and delete database data from code behind using asp.net C# C#asp.net WebForm添加JS并从后面的代码运行 - C# asp.net WebForm add JS and run it from code behind 如何将全局字符串变量从ASP.NET页后面的C#代码传递到经典ASP页? - How to pass a Global String Variable from the C# code behind of an ASP.NET page to a classic ASP page? C#ASP.NET使用来自ASP.NET背后代码的布尔变量 - C# ASP.NET using Boolean variable from code behind in ASP.NET ASP.NET通过后面的代码将onclick添加到div - ASP.NET add onclick to div via code behind 如何在后面的代码中创建Runat服务器DIV? ASP.NET和C# - How to create a runat server DIV in the behind code ? ASP.NET & C# 按钮焦点在 JQuery 从页面后面的代码显示时对话框不起作用 - asp.net / c# - Button focus on JQuery Dialog doesn't work when showing from code behind the page - asp.net / c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM