我不想从后面的代码为图像注册 OnMouseOver 和 OnMouseOut-Event,因为无论用户是否登录,我都必须有所不同。 有什么想法吗?
最佳答案
您可以向对象添加属性。
例如
Image img = new Image();
img.Attributes.Add("onmouseover", "myjavascriptfunction();");
要根据对象的 id 设置参数,使用:
Image img = new Image();
img.Attributes.Add("onmouseover", "myjavascriptfunction(" + img.ClientID + ");");
关于asp.net - 从 CodeBehind 注册 OnMouseOver-Event?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1713884/