Avatar of sqdperu
sqdperu
Flag for United States of America

asked on 

How can I fire an OnClick event inside of SVG tags on Text tag? (event in VB code-behind in APS.NET webforms app)

Using VS 2017.  ASP.NET / VB.NET Web forms app.

I currently have SVG code in my ASP that will hide/show a hyperlink based on conditions in the VB code-behind.  The code behind also builds and provides the URL for the link.  This code works:

<svg viewBox="0, 0, 1200, 153" preserveAspectRatio="xMinYMin meet"  style="position: absolute" >
   <%-- Various SVG code for Cirles, Lines, and Text --%>         <%-- NOTE: in order to reference in code behind to set visible=false, you must have 'runat="server"' on <a> tag. --%>         <%-- Code behind will supply the URL and hide show link based on criteria. --%>         <a id="lnkDoc" href="." target="_blank" runat="server">                   <text x="738" y="150" text-anchor="start" font-size="11" font-family="sans-serif" text-decoration="underline" fill="#3f48cc" cursor="pointer">                    View doc               </text>         </a> </svg>

Open in new window

Now I no longer can use a hyperlink.  I now need a link button or something that will fire event code in the code-behind based on an on-click event.

I have tried adding an "onclick="DocEvent_Click" to the <text> tag above and that did not work.  I then replaced the <a> tag above with this code:

<a id="lnkDoc" href="." target="_blank" runat="server" visibility="visible">     
       <asp:LinkButton ID="btnDoc" runat="server" x="1055" y="150" Font-Underline="True" OnClick="DocEvent_Click" >View doc</asp:LinkButton>
</a>

Open in new window

It also did not work.  It does not even show the "View doc" text.


What is the easiest way I can add Text inside of the SVG tags that will fire an event in the VB code-behind when clicked?  

(NOTE: I also need to be able to show / hide the text based on a condition in the code- behind.)


Thanks



ASP.NETVisual Basic.NET* SVG

Avatar of undefined
Last Comment
sqdperu

8/22/2022 - Mon