Asp:HyperLink onmouseover and onmouseout

507 Views Asked by At

How could i do like this but using a <asp:HyperLink> instead?

 <li><a href="/url/"  
    onmouseover="mopen('m1')" 
    onmouseout="mclosetime()">Link</a>

    <div id="m1" 
        onmouseover="mcancelclosetime()" 
        onmouseout="mclosetime()">
    <a href="/url1/">Link1</a>
    <a href="/url2/">Link2</a>

    </div>

</li>
2

There are 2 best solutions below

0
On BEST ANSWER

Sure you can. You will need to use codebehind to add attributes.

hyperlinkID.Attribues.Add("onmouseover","mopen('m1')");
hyperlinkID.Attribues.Add("onmouseout","mclosetime()"")

and replace your link with

<asp:HyperLink  ID = "hyperlinkID" NavigateURL="/url/" Text="Link" runat="server" /> 
0
On

You can add any attributes in a <asp:HyperLink> and those will be passed to the rendered <a>.

For example, this ASP.NET markup

<asp:HyperLink ID="HyperLink1" runat="server" 
               onmouseover="mopen('m1')" 
               onmouseout="mclosetime()" Text="Some Link">
</asp:HyperLink>

Will give this HTML

<a id="HyperLink1" onmouseover="mopen('m1')" onmouseout="mclosetime()">Some Link</a>