日期:2014-05-17 浏览次数:20401 次
<%@ Page Language="C#" Debug="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> String[] data = { "A", "B", "C" }; String[] url = { "http://avatar.profile.csdn.net/C/9/4/2_net_lover.jpg", "http://avatar.profile.csdn.net/B/3/8/2_huaxinyuanshuai.jpg", "http://avatar.profile.csdn.net/D/E/5/2_smith_hjq.jpg" }; protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { int count = Int32.Parse(HiddenField1.Value) + 1; if (count >= data.Length) count = 0; HiddenField1.Value = count.ToString(); Literal1.Text = data[count]; ImageButton1.ImageUrl = url[count]; } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Literal1.Text = data[0]; ImageButton1.ImageUrl = url[0]; } } </script> <html> <head> <title></title> </head> <body> <form id="form1" runat="server"> <asp:Literal ID="Literal1" runat="server"></asp:Literal> <asp:ImageButton ID="ImageButton1" runat="server" OnClick="ImageButton1_Click" /> <asp:HiddenField ID="HiddenField1" runat="server" Value="0" /> </form> </body> </html>