关于QQ空间相册功能的构想与简单实现

QQ空间上传照片对其可以分类,形成不同的相册,这对于用户体验来说是很不错的,如果用户只能上传不加以分类,那么用户体验会很差。

下面是自己关于相册功能实现的一些简单看法:

首先,是创建相册,可以用panel将控件隐藏,给用户更好体验。

<asp:Button ID="creatphoto" runat="server" OnClick="creatphoto_Click" Text="创建相册" />
<asp:Panel ID="pn_creatphoto" runat="server" Visible="false" >
相册名称: <asp:TextBox ID="photoname" runat="server" ></asp:TextBox><br />
<asp:Button ID="yes" runat="server" Text ="确定" OnClick="yes_Click" /><br />
<asp:Button ID="no" runat="server" Text="取消" OnClick ="no_Click" />
</asp:Panel>

 

第二,在Repeater空间中将所有的相册名列出,数据绑定,使用图片按钮控件。

<asp:Repeater ID="Rptphoto" runat="server" OnItemCommand="Rptphoto_ItemCommand" > 
<HeaderTemplate> 
<table>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td>
<asp:Label ID="photoname" runat="server" Text='<%# Eval("photoname") %>'></asp:Label><br />
<asp:ImageButton ID="photo" runat="server" Width ="100" Height="100" ImageUrl='<%#Eval("cover") %>' CommandName="Photo" CommandArgument='<%#Eval("photoname") %>' />
</td>
<td><asp:LinkButton ID="lbtDelete" runat="server" Text="删除" CommandName="Delete" CommandArgument='<%#Eval("photoname") %>' ></asp:LinkButton></td>
</tr>

</ItemTemplate>

<FooterTemplate>
</table>

</FooterTemplate>
</asp:Repeater>

 

最后,点击不同的图片按钮,用session传值的方式把对应相册名称下的图片提出来。

用repeater显示

<asp:Repeater ID="Rptphoto" runat="server" OnItemCommand="Rptphoto_ItemCommand" > 
<HeaderTemplate> 
<table>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td>
<img src='<%# Eval("photo") %>' runat="server" width="100" height="100" />
</td>
<td>点赞:<%# Eval("good")%></td>
<td><asp:LinkButton ID="lbtGood" runat="server" Text="点赞" CommandName="Good" CommandArgument='<%#Eval("id") %>' ></asp:LinkButton></td>
<td><asp:LinkButton ID="lbcover" runat="server" Text="设为封面" CommandName="Cover" CommandArgument='<%#Eval("id") %>'></asp:LinkButton></td>
<td><asp:LinkButton ID="lbtDelete" runat="server" Text="删除" CommandName="Delete" CommandArgument='<%#Eval("id") %>' ></asp:LinkButton></td>
</tr>

</ItemTemplate>

<FooterTemplate>
</table>

</FooterTemplate>
</asp:Repeater>

 

如此,便完成了相册功能的实现,具体后台代码不难写,主要是要和相应的数据库吻合。

效果图见下:

 

posted @ 2016-11-29 21:07  WhiteBlackCat  阅读(835)  评论(0编辑  收藏  举报