It's there a way i can control the ID of my HtmlGenericControl.
I try to create my own HtmlGenericControl and override UniqueID, ClientID, onPreRender etc ... but nothing work
The following article demonstrates how to override controls your own ID's. Whilst it does not show how to do it for htmlgenericcontrol it should be pretty easy to figure out from all the other examples.
您无需覆盖此全部,只需覆盖渲染并手动执行所有操作
The HtmlGenericControl can be manually given a client Id by adding the id
attribute:
var bob = new HtmlGenericControl("div")
{
InnerHtml = "give me an Id!"
};
bob.Attributes.Add("id", "myId");
this.Page.Controls.Add(bob);
The Id given will only be accessible from the client side (eg JavaScript).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.