Hola a todos...
Necesito agregar un evento a un ASP CheckBox, como todos saben cuando un ASPCheckBox se renderiza produce el siguiente HTML.
Consideren que esto se ejecuta en el ItemDataBound de un DataGrid.
Control ASPNET
Código:
<asp:CheckBox id="chkRechazar" runat="server"></asp:CheckBox>
Html generado
Código:
<input id="dgrProblemas_1_chkRechazar" type="checkbox"
name="dgrProblemas:1:chkRechazar" />
Lo que hago es lo siguiente:
Código:
e.Item.ID = e.Item.ID+count;
((CheckBox)e.Item.FindControl("chkRechazar")).Attributes.Add("onblur",
string.Format("javascript:SelectItemGrid({0},this)",
e.Item.ClientID));
((CheckBox)e.Item.FindControl("chkRechazar")).Attributes.Add("onclick",
string.Format("javascript:SelectItemGrid({0},this)",
e.Item.ClientID));
Y el codigo que me genera es:
Código:
<span onblur="javascript:SelectItemGrid(dgrProblemas_1,this)">
<input id="dgrProblemas_1_chkRechazar" type="checkbox"
name="dgrProblemas:1:chkRechazar"
onclick="javascript:SelectItemGrid(dgrProblemas_1,this)" />
</span>
Pero yo necesito que los eventos sean asignados al checkbox y no al SPAN, algo asi:
Código:
<input id="dgrProblemas_1_chkRechazar" type="checkbox"
name="dgrProblemas:1:chkRechazar"
onclick="javascript:SelectItemGrid(dgrProblemas_1,this)"
onblur="javascript:SelectItemGrid(dgrProblemas_1,this)"
/>
Espero puedan ayudarme...
Saludos.