Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > gridview and attribute

Reply
Thread Tools

gridview and attribute

 
 
Al Smith
Guest
Posts: n/a
 
      05-15-2006
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




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Complex attribute with Attribute and simpletype kanpeter XML 0 10-26-2010 09:41 AM
attr_reader, default attribute value, and rdoc of attribute dkmd_nielsen Ruby 6 11-26-2008 05:40 PM
Difference between empty attribute and undefined attribute jpdogg@gmail.com Javascript 4 04-24-2007 02:52 PM
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM
XSLT: Making attribute to parent attribute Bostonasian XML 1 09-18-2005 07:30 AM



Advertisments