Finally figured out a solution for anyone interested...
Use this javascript function, it takes in the id of the gridview button,
then takes the current backcolor of the gridview row (so it can be rest if
you press cancel), and then returns true or false to the call.
<script type="text/javascript" language="javascript">
function ConfirmDelete(ID)
{
var CurrentBackColour = ID.parentElement.parentElement.style.backgroundCol or;
ID.parentElement.parentElement.style.backgroundCol or='red';
var result = confirm('Are you sure you want to Delete this Line Item?');
if (result == false)
{
ID.parentElement.parentElement.style.backgroundCol or=CurrentBackColour;
}
return result;
}
</script>
then in the itemtemplate in your gridview just set the OnClientClick='return
ConfirmDelete(this);' for the button .
"NH" wrote:
I have a gridview with a delete button as follows...
<ItemTemplate>
<asp:ImageButton id="deleteAttachment" OnClientClick='return
confirm("Are you sure you want to delete this Attachment?");'
imageallign="absbottom" commandName="DeleteAttachment" tooltip="Delete this
Attachment" imageurl="images/icons/delete.jpg"
runat="server"></asp:ImageButton>
</ItemTemplate>
Is it possible to highlight the gridview row or change the background color
of the row when its clicked? It will have to be a client side thing
obviously. I guess the OnClientClick property will reference a script
function but how do I know which row was clicked? And what client side code
is required to change the background color of a gridview row?
Or is this possible?
thanks