473,322 Members | 1,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Client side gridview click

NH
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
Nov 27 '06 #1
2 12139
OnClientClick='return imageButtonClicked(this)';

"this" refers to the html element created by asp.net for the ImageButton. If
you view the page's html source in your browser, you will see exactly what
it is and where it is located. Likely, it is located inside a <tdand the
<tdis inside the <tr>. This is your row. You can navigate to the row with
parentElement property.

Make a css style for a highlighted row. Once you navigate to the row, set
its className property to that style name.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"NH" <NH@discussions.microsoft.comwrote in message
news:31**********************************@microsof t.com...
>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

Nov 27 '06 #2
NH
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
Nov 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stephen | last post by:
Hey Everyone, I have a problem with a web application due to the use of both client-side and server side script on the on-click event of a button. The client side script runs first as expected...
1
by: Stephen | last post by:
Hey All, I have a problem with a web application due to the use of both client-side and server side script on the on-click event of a button. The client side script runs first as expected however...
3
by: Borr | last post by:
Hi, I have an ASP .NET page, that runs client side timer that does something on the Server side and after that loads another page. So I have on client side something like : function...
1
by: rmgalante | last post by:
I have written an ASP.Net application that uses the standard client-side and server-side validation for various fields on the form. Some of the customers that use the form report symptoms that...
0
by: NH | last post by:
I know how to make client side paging work in the gridiew control using a sqlDataSource (and it works great!). But how can I "code" this i.e. I want to use a dataset as the datasource of the...
2
by: henk | last post by:
Hi, How can i eassely add client side script in my code. I have a sort of TAB control, that works through postbacks but i want the action taken on the client side. Thus when i click on a link a...
0
by: rupinderbatra | last post by:
Hi, I want to implement a client side filter box for a Gridview server control. I dont want to do it server side or AJAX based because the existing architecture does not allow that much...
0
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, imagine this for a moment if you will: i have a row in a gridview that when it is in edit mode there is a column that contains a dropdownlist and 2nd column that contains a user control....
5
AnuSumesh
by: AnuSumesh | last post by:
Hi All, I am using <asp:Gridview> to display my data. I am adding columns and rows dynamically. I am facing following issues: 1. I want scrollbars around the gridview and for this purpose i...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.