A
Al Smith
I am trying to attach client side javascript to a check box contained within
the gridview control using the attribute method. My aspx code is:
<asp:TemplateField HeaderText="Set Password">
<EditItemTemplate>
<asp:CheckBox ID="chkSetPassword" runat="server" Checked='<%#
Bind("SetPassword") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSetPassword" runat="server" Checked='<%#
Bind("SetPassword") %>'
Enabled="false" />
</ItemTemplate>
</asp:TemplateField>
In the code behind, RowCreated() event I use the chk.Attributes to attempt
the wiring of the onclick event to my JS:
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowState == DataControlRowState.Edit) {
CheckBox chk = (CheckBox)e.Row.FindControl("chkSetPassword");
if (chk != null){
chk.Attributes["onclick"] = "javascriptnclickSetPassword();";
}
}
}
When I do a view source in the browser I get:
<input id="GridView1_ctl02_chkSetPassword" type="checkbox"
name="GridView1$ctl02$chkSetPassword" onclick="flagDataChanged(this);" />
Is there a was to add my JS event to this?
Thanks
Al
the gridview control using the attribute method. My aspx code is:
<asp:TemplateField HeaderText="Set Password">
<EditItemTemplate>
<asp:CheckBox ID="chkSetPassword" runat="server" Checked='<%#
Bind("SetPassword") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSetPassword" runat="server" Checked='<%#
Bind("SetPassword") %>'
Enabled="false" />
</ItemTemplate>
</asp:TemplateField>
In the code behind, RowCreated() event I use the chk.Attributes to attempt
the wiring of the onclick event to my JS:
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowState == DataControlRowState.Edit) {
CheckBox chk = (CheckBox)e.Row.FindControl("chkSetPassword");
if (chk != null){
chk.Attributes["onclick"] = "javascriptnclickSetPassword();";
}
}
}
When I do a view source in the browser I get:
<input id="GridView1_ctl02_chkSetPassword" type="checkbox"
name="GridView1$ctl02$chkSetPassword" onclick="flagDataChanged(this);" />
Is there a was to add my JS event to this?
Thanks
Al