asp.net 留言板

来源:百度知道 编辑:UC知道 时间:2024/06/09 22:14:47
我想在留言板中能添加表情进去,代码如下:
<div align="right">
个人形象:</div>
</td>
<td nowrap="nowrap" style="height: 125px; width: 552px;">
<div align="left">
<asp:DropDownList ID="face" runat="server" onChange="tupian1.src='images/userface/'+(this.options.selectedIndex)+'.gif';" Width="63px">
</asp:DropDownList>
<img id="Img2" align="absMiddle" language="javascript" name="tupian1" onclick="return img2_onclick()"
src="images/userface/0.gif" /></div>
但是选中DropDownList中的选项时候,表情没反应,是不是要写img2_onclick()函数?怎么写?急急急急急急急急急急

<asp:DropDownList ID="face" runat="server" onChange="tupian1.src='images/userface/'+(this.options.selectedIndex)+'.gif';" Width="63px">
</asp:DropDownList>
加上一个 AutoPostBack=True 这样才有反应,也要写个后台事件
在页面上双击一下这个页面就会添加上事件了
加完是这样的:
<asp:DropDownList ID="face" runat="server" AutoPostBack=True OnSelectedIndexChanged="face_SelectedIndexChanged" Width="63px">
</asp:DropDownList>
后台会有一个:
protected void face_SelectedIndexChanged(object sender, EventArgs e)
{ //在里面写:
tupian1.src='images/userface/'+(face.SelectValue)+'.gif';
}

网上有很多,查一下吧。。