求助 CSS 问题(完整)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head runat="server">
<title>无标题页</title>
<style type="text/css">
.img
{
margin:10px 0px 0px -56px; outline:none;
}
.imagebutton
{
margin:0px 0px 0px -56px;outline:none;
}
#Panel1
{
padding:0px 0px 0px 80px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" Height="120px" BackColor="Azure">
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Default5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
CreateImage();
}
protected void CreateImage()
{
for (int m = 0; m < 3; m++)
{
ImageButton bt = new ImageButton();
bt.CssClass = "img";
bt.Width = 71;
bt.Height = 96;
bt.ImageUrl = "i/" + m.ToString() + ".jpg";
bt.Click += new ImageClickEventHandler(bt_Click);
Panel1.Controls.Add(bt);
}
}
void bt_Click(object sender, ImageClickEventArgs e)
{
ImageButton bt = (ImageButton)sender;
string ss = bt.ImageUrl;
if (bt.CssClass == "imagebutton")
bt.CssClass = "img";
else
bt.CssClass = "imagebutton";
}
按钮数为1时运行正常,多个时无效。