[英]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.