1
我想在網站上添加動態圖像按鈕沒有圖像按鈕的ID,所以我使用ASP標記生成與ParseControl方法的動態控制,它的工作,但事件並沒有點擊圖像按鈕時被觸發事件不工作與ParseControl方法
Default.aspx.cs代碼
protected void Page_Load(object sender, EventArgs e)
{
string str = @"<asp:ImageButton runat=server ImageUrl=""~/close-icon (1).png"" OnClick=""click"" />";
Control c = Page.ParseControl(str);
form1.Controls.Add(c);
}
protected void click(object sender, ImageClickEventArgs e)
{
Response.Write("Image Clicl");
}
Default.aspx的代碼
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
請幫我在解決方案,使得代碼來解決我的問題。