我想添加带有 onserverclick 属性的“a”标签
我正在使用以下代码。但 onserverclick 事件未触发(不工作)
onserver点击:
protected void Pagination_Click(object sender, EventArgs e)
{
}
我的 C# 代码:
HtmlGenericControl li = new HtmlGenericControl("li");
olpage.Controls.Add(li);
HtmlGenericControl a = new HtmlGenericControl("a");
a.Attributes.Add("ID", i.ToString());
a.Attributes.Add("onserverclick", "Pagination_Click");
a.InnerHtml = i.ToString();
li.Controls.Add(a);
HTML 代码:
<%@ Master Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"CodeFile="Products.master.cs" Inherits="Productmaster"%>...
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">...
<div class="pages">
<ol id="olpage" runat="server">
</ol>
</div>...