¿Cómo invocar la función JavaScript al hacer clic en un hipervínculo dentro de un informe en ASP .NET?
Question: ¿Cómo invocar la función JavaScript al hacer clic en un hipervínculo dentro de un informe en ASP .NET?
Answer:
Puede escribir un código JS en el objeto TextObject.Huperlink object(javascript:alert('¡Ha hecho un clic!!')).
O escribir la función en el fichero *.aspx(cshtml):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestInheritReports._Default" %> <%@ Register assembly="FastReport.Web" namespace="FastReport.Web" tagprefix="cc2" %> <script type="text/javascript"> function count_rabbits() { for(var i=1; i<=3; i++) { alert("Pull out from hat rabbit " + i +" !") } } </script> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml">; <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> </div> <cc2:WebReport ID="WebReport1" runat="server" /> </form> </body> </html> |
Y invocar la función:
TextObject1.Hyperlink = "javascript:count_rabbits()";