添加/使用ASP.Net控件的属性

添加/使用ASP.Net控件的属性,asp.net,attributes,Asp.net,Attributes,我想知道在哪里可以获得可以添加到ASP.NET控件的属性列表。 例如,以下代码块来自: protected void Grid1_OnItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { ((CheckBox)item["TestColumn"].Controls[0]).Attributes.Add("onClick","javascript:hi();")

我想知道在哪里可以获得可以添加到ASP.NET控件的属性列表。 例如,以下代码块来自:

protected void Grid1_OnItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
      ((CheckBox)item["TestColumn"].Controls[0]).Attributes.Add("onClick","javascript:hi();");
    }
}
以下代码无法工作,我认为可能是因为“onClick”不适用于复选框ASP.NET控件

因此,是否有一个地方可以为属性提供参考,以便添加到每个ASP.NET控件?以及以下代码:

Attributes["click"] = abc();

谢谢。

必须在GridView的RowCreated事件中添加属性。请在下面查看

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

// Dummy Code
Button btnButton =
(Button)e.Row.Cells[4].FindControl("btnButton");
btnButton.Attributes.Add("onmouseover",
"this.className='actionH'");

}
}

好啊但是我们如何知道每个控件可以使用哪些属性呢?谢谢