Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to call javascript from asp.net HyperLink control

I simply want to call a JavaScript function from asp.net hyperlink im using http://orangoo.com/labs/GreyBox/ my requirement is to show thumbnail on hyperlink and on click show full image. Should I use another control? my code is below:

<asp:HyperLink ID="Hyperlink" runat="server" CssClass="Screenshot" ImageUrl="App_Themes/White/Images/thmb_screenshot_1.png"
                        NavigateUrl="App_Themes/White/Images/screenshot_1.png" ToolTip="screenshot 1"   />   

<script language="javascript" type="text/javascript">     
    //Greybox Image popup window
    function OpenImage(url) {
        var caption = "Home";
        return GB_showImage(caption, url)
    }         
</script>

how can I use

onclick="OpenImage(this.src);
or 
OnClientClick="OpenImage(this.src);
like image 942
skhurams Avatar asked Dec 01 '22 06:12

skhurams


1 Answers

I know this is old but to anyone interested, just add onclick and it will work fine. The extra attribute (even though it doesn't show up on intellisense) will pass through to the rendered markup.

            <asp:HyperLink ID="HyperLink4" runat="server" onclick="logDownload();" NavigateUrl="~/download/Sample-Icons.zip">Download Icons</asp:HyperLink>
like image 149
KingOfHypocrites Avatar answered Dec 10 '22 21:12

KingOfHypocrites