B
Brian Lorraine
I've learned how to add javascript to a web control in .NET using the
".Attributes.Add" method.
example:
MYBUTTON.Attributes.add("onClick", "blablafunction")
I'm having a problem adding javascript to a control that is inside a
TEMPLATE COLUMN of a datagrid. The name of my button is "button1". Because it
is in a template column, you can't just type:
button1.attributes.add........
You also can't go this route
DataGrid.FindControl("button1").Attributes.Add.... because the control item
doesn't have an ATTRIBUTES property.
I tried casting it:
Dim testbutton As Button
testbutton = CType(DataGrid.FindControl("button1"), Button)
But testbutton still doesn't have the ATTRIBUTES property.
I tried having a javascript function fire off when the page loads which
which would add some javascript to the button:
document.getElementById("BUTTONID").onclick = function() { blablabla}
This works when a button has a STATIC ID, but if a control is INSIDE a
templatecolumn, .NET will actually give the ID of this control something
completely different everytime you run it depending upon how much information
is in the datagrid.
I've spent all day trying to figure this out, digging throughMSDN articles,
newsgroups, but can't find anywhere else to look. The only thing I can think
of that SHOULD work is to cast the control to a button, but for some reason
this isn't working. Does anyone know a way I can convert this control using
vb.net which would expose the .attributes tag so I can finally add an onclick
event to this buton?
Any help or links appreciated
A desperate,
B
".Attributes.Add" method.
example:
MYBUTTON.Attributes.add("onClick", "blablafunction")
I'm having a problem adding javascript to a control that is inside a
TEMPLATE COLUMN of a datagrid. The name of my button is "button1". Because it
is in a template column, you can't just type:
button1.attributes.add........
You also can't go this route
DataGrid.FindControl("button1").Attributes.Add.... because the control item
doesn't have an ATTRIBUTES property.
I tried casting it:
Dim testbutton As Button
testbutton = CType(DataGrid.FindControl("button1"), Button)
But testbutton still doesn't have the ATTRIBUTES property.
I tried having a javascript function fire off when the page loads which
which would add some javascript to the button:
document.getElementById("BUTTONID").onclick = function() { blablabla}
This works when a button has a STATIC ID, but if a control is INSIDE a
templatecolumn, .NET will actually give the ID of this control something
completely different everytime you run it depending upon how much information
is in the datagrid.
I've spent all day trying to figure this out, digging throughMSDN articles,
newsgroups, but can't find anywhere else to look. The only thing I can think
of that SHOULD work is to cast the control to a button, but for some reason
this isn't working. Does anyone know a way I can convert this control using
vb.net which would expose the .attributes tag so I can finally add an onclick
event to this buton?
Any help or links appreciated
A desperate,
B