简体   繁体   English

Asp.Net MVC在网页中显示图像?

[英]Asp.Net MVC Displaying Image in webpage?

I retrived 9 image paths from DB which i stored when user registers.... In one page i have to display 3 images in each row ...How to do that... 我从DB中检索了9条图像路径,当用户注册时我存储了这些图像。...在一页中,我必须在每行中显示3张图像...该怎么做...

I created model class "FriendsList" with variable image Path and User id... 我创建了具有可变图像路径和用户ID的模型类“ FriendsList”。

public String FriendImagePath
{
    get;
    set;
}

public int FriendUserId
{
    get;
    set;
}

And i created view model class and created a variable "FriendsList " of type Model class... 我创建了视图模型类,并创建了模型类类型的变量“ FriendsList” ...

public List<FriendsList> FriendsList { get; set; }

I stored 9 values in this... 我在其中存储了9个值...

In .Aspx page i Have to display 3 row.. and in each row i have to display 3 image... 在.aspx页面中,我必须显示3行..在每一行中,我必须显示3张图像...

How to do this ??? 这个怎么做 ???

<tr>

<td></td>

<td></td>

<td></td>

</tr>

<tr>

<td></td>

<td></td>

<td></td>

</tr>

<tr>

<td></td>

<td></td>

<td></td>

</tr>

I have to display like this 我必须这样显示

How to do this... 这个怎么做...

Thank you.. 谢谢..

<table>
<tr>   
<% 
   int index=0;
   foreach(var friend in Model){ %>
      <% if(index%3==0){ %>
           </tr><tr>
      <% } %>   
    <td><img src="<%=Url.Content(friend.FriendImagePath) %>" /></td>
    //others prpoerties
<% 
   index++;
 } %>
</tr>
</table>

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM