Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/03/2007, 16:59
lang.net
 
Fecha de Ingreso: diciembre-2004
Mensajes: 130
Antigüedad: 19 años, 5 meses
Puntos: 0
Exclamación Attribute.Add(jscript)

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.
__________________
langdotnet