This is a migrated thread and some comments may be shown as answers.

Is it possible to implement to trigger an extra event/function when clicking the file links

1 Answer 11 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Brent
Top achievements
Rank 1
Brent asked on 27 Nov 2013, 08:10 AM

Hi Telerik,

I use a radGridviews to implement a system which supports downloading files from IIS server.

The column setting is shown below,
<telerik:GridHyperLinkColumn DataTextField="File Name" HeaderText="File Name" UniqueName="File Name" DataNavigateUrlFormatString="IIS_ItemServer\{0}" DataNavigateUrlFields="File Path" />

In addition to downloading files,

is it possible to implement to trigger an extra event/function when clicking the file links by this way?

Thanks you

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 29 Nov 2013, 03:08 PM
Hi Brent,

First I would like to point out that the UniqueName of a columns could not contain spaces, so you should rename the UniqueName of the column to "FileName".

Now, moving to your requirement. For handling the click event on the GridHyperLinkColumn hyperlink you could handle the server-side ItemDataBound event, get reference to the HyperLink control of the column and add event handler for the client-side "onclick" event. Below is a sample example for adding the event handler:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = e.Item as GridDataItem;
        HyperLink button = item["FileName"].Controls[0] as HyperLink;
        button.Attributes.Add("onclick", "onHyperLinkClick()");
    }
}
And the JavaScript:
<script type="text/javascript">
    function onHyperLinkClick() {
        // your custom logic
    }
</script>

Hope that helps.


Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
GridView
Asked by
Brent
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or