Select A Tag

Last post 01-15-2014, 9:46 AM by AndyFel. 2 replies.
Sort Posts: Previous Next
  •  01-15-2014, 6:13 AM 78765

    Select A Tag

     Hi

     

    In the previous editor we created a custom form which allowed us to replace the selected A tag with new settings. The user could select the A tag just by clicking somewhere in it then pressing a custom button. 

     

    We used to use SearchSelectionElement("a") to get the whole A tag, I have tried to use ExtractRangeNodes() but this comes back empty. You must be able to do this because your properties dialog knows its in an a tag by just clicking anywhere in the a tag. Can you give me a code segment which will allow me to get the whole a  tag without physically selecting it all in the browser.

     

    thanks 

  •  01-15-2014, 8:45 AM 78768 in reply to 78765

    Re: Select A Tag

    Hi AndyFel,

     

    Please try the example below, it shows you how to get the link code.

     

    1. <%@ Page Language="c#" %>  
    2.   
    3. <%@ Register TagPrefix="RTE" Namespace="RTE" Assembly="RichTextEditor" %>  
    4.   
    5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    6. <html xmlns="http://www.w3.org/1999/xhtml">  
    7. <head>  
    8.     <title></title>  
    9.     <script runat="server">  
    10.         protected override void OnLoad(EventArgs e)  
    11.         {  
    12.             Editor1.Text = "<a href='http://www.google.com'>test</a>";  
    13.             base.OnLoad(e);  
    14.         }  
    15.     </script>  
    16. </head>  
    17. <body>  
    18.     <form id="Form1" method="post" runat="server">  
    19.   
    20.         <RTE:Editor runat="server" ID="Editor1"/>  
    21.         <input type="button" value="Get Link Code" onclick="getPointCode()" />  
    22.     </form>  
    23. </body>  
    24. </html>  
    25. <script type="text/javascript">  
    26.     function getPointCode()  
    27.     {  
    28.         var editor1 = document.getElementById('<%= Editor1.ClientID%>').editor;  
    29.         alert(editor1.GetPointNode().GetParent().GetHtmlCode());  
    30.     }  
    31.  </script>  
     

    Regards,

     

    Ken 

  •  01-15-2014, 9:46 AM 78770 in reply to 78768

    Re: Select A Tag

     Cool thanks it does just what I want.
View as RSS news feed in XML