Question: I'm having a hard time getting a javascript confirm box from asp:buttonfield:

This is the original code of the Gridview, however buttonfield does not seem to accept "onClientClick"

```
<asp:GridView ID="gvNavios" runat="server"  onrowcommand="gvNavios_RowCommand">
<Columns>
    <asp:ButtonField runat="server" ButtonType="Button" Text="delete" CommandName="Eliminar" />
</Columns>
</asp:GridView>

```

So I tried asp:Linkbutton instead:

```
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
     <asp:LinkButton ID="eliminar" CommandName="delete" runat="server" Text="delete"/>
</ItemTemplate>
</asp:TemplateField>

```

However this way I cannot get which row was clicked as e.commandargument is not filled

The C# code-behind: 

```
 protected void gvNavios_RowCommand(object sender, GridViewCommandEventArgs e)
{

    string currentCommand = e.CommandName;
    int currentRowIndex = Int32.Parse(e.CommandArgument.ToString());
    string imo = gvNavios.Rows[currentRowIndex].Cells[3].Text;

    if (currentCommand.Equals("delete"))
    {
        eliminarNavio(imo);
        Response.Redirect(Request.RawUrl);
    }

```

}

I appreciate one of the following: Insert javascript in asp:button, or get Row number from linkbutton.

Answer: 
This problem was solved in another question I subsequently asked which can be found here... [iOS - Math help - base image zooms with pinch gesture need overlaid images adjust X/Y coords relative](https://stackoverflow.com/questions/10709280/ios-math-help-base-image-zooms-with-pinch-gesture-need-overlaid-images-adjus)

Basically, I used a scrollView instead and used the following calculations for positioning x, y...

```
newX = (pin.baseX * scrollView.zoomScale) + 
    (((pin.frame.size.width * scrollView.zoomScale) - 
    pin.frame.size.width) / 2);
newY = (pin.baseY * scrollView.zoomScale) + 
    ((pin.frame.size.height * scrollView.zoomScale) - 
    pin.frame.size.height);

```

Note: 'pin' is a custom object that inherits from UIImageView which has properties 'baseX' and 'baseY' where I store the original x/y coordinates of the pin at zoomScale 1.0. See the link above for sample of my full implementation. Thanks.
You have to be working out the coordinates for the pins in a mathematical way rather then using pixels for example if your image was 100 x 100 and you wanted to put the pin in the centre point of the map rather then setting the x and y coordinates to (50, 50) you set them to (image.size.width/2,image.size.height/2) because if you were to then scale the view down the pin would remain in the centre point.

Obviously this is a fairly basic example but the same logic can be applied wherever you put the pin on the image.

Hope this helps.

OR

You could work out your new coordinates by how much the image is being scaled. If the image was again 100 x 100 and you scaled it down to 50 x 50 and you wanted your pin to remain in the same place you would do (x / (100/50), y / (100/50))

The formula would be:

x = x / (original width / new width) 

y = y / (original height / new height)