我试图调用点击事件,但它没有调用它我试过这个代码:比如
objImage.Click += new ImageClickEventHandler(WebForm4.ImageButtons_Click);
objImage.Click += WebForm4.ImageButtons_Click;
我的代码:
public HtmlGenericControl CreateDIV_OyVerme_Sub_Yildiz(string id, int subId)
{
HtmlGenericControl objDiv = new HtmlGenericControl("div");
objDiv.ID = strControlName_DivYildiz + id + "_" + subId;
objDiv.Attributes.Add("class", strClassName_DivYildiz);
//objDiv.Attributes.Add("runat", "server");
ImageButton objImage = new ImageButton();
objImage.Attributes.Add("runat", "server");
objImage.CommandArgument = id;
//objImage.Src = strImgSrc_yildiz;
objImage.Click += new ImageClickEventHandler(WebForm4.ImageButtons_Click);
//objImage.Click += WebForm4.ImageButtons_Click;
objImage.Attributes.Add("onclick", "WebForm4.ImageButtons_Click();");
objImage.ID = strControlName_ImageYildiz + id +"_" + subId;
objImage.ImageUrl = strImgSrc_yildiz;
objImage.OnClientClick = strOnClientClickFunc_yildiz;
// objImage.Attributes.Add("OnClick","WebForm4.amethod (o;");
objImage.Style.Add(HtmlTextWriterStyle.Height, "19px");
objImage.Style.Add(HtmlTextWriterStyle.Width, "20px");
objImage.Style.Add(HtmlTextWriterStyle.BorderWidth, "0px");
objImage.Style.Add(HtmlTextWriterStyle.Position, "relative");
objImage.Style.Add(HtmlTextWriterStyle.Top, "13px");
objImage.Style.Add(HtmlTextWriterStyle.Left, "6px");
objImage.Style.Add("float", "left");
objImage.ToolTip = subId + "/" + 5;
// calling the method
// objImage.Attributes.Add("OnClientClick", "return(GetRssID(objRssItem));");
// var duck = objRssItem;
// objImage.Click += (s, e) => { WebForm4.amethod(objRssItem); };
//objImage.Click += WebForm4.amethod (objRssItem);
objDiv.Controls.Add(objImage);
return objDiv;
}