It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming ASP & ASP.NET Forum

Real-time highlighting txt in a HTML website

Real-time highlighting txt in a HTML website

Postby zephere on Mon Jun 21, 2010 3:14 pm

hey guys,

Is there any way to insert tags into a webpage in real-time?

Here is what I want to do. I have a body of text displayed on a webpage. I want to add a comment on a particular line of text by clicking a button, then highlighting a portion of the text. On mouse release, an ajax box would appear and the user can place their comments in there. when the user has done commenting, they just click the "done" button to save all the comments on the body of text for all to see. Much like a modified version of facebook's photo tagging system but for text.

My idea of implementing this is to add tags at the beginning and the end of the selected portion of text and including an id to save it into the database. But how do I do that if it is possible? is there any opensourced software readily available that I can use in ASP.NET?

Sorry if i asked some stupid questions here, I am new and would like to learn more.
zephere
 
Posts: 1
Joined: Mon Jun 21, 2010 2:54 pm

Re: Real-time highlighting txt in a HTML website

Postby HotNoob on Thu Sep 23, 2010 8:40 pm

you will most definitely need to use JavaScript with a combination of ASP.net

There are 2 ways that you can send over the data to the server without changing the page, you can 1, use ajax, or 2 use a hidden iframe. i personally prefer the iframe way, because there are no content limitations, where there are with ajax.

As for getting what they select, just use this function that i quickly wrote up:
Code: Select all
<script>
    function getSelectedText()
    {
        var txt = '';
     if (window.getSelection)
      {
         txt = window.getSelection();
       }
      else if (document.getSelection)
       {
         txt = document.getSelection();
        }
       else if (document.selection)
       {
         txt = document.selection.createRange().text;
        }
      return txt;
    }
</script>


That's probably all you need, the rest i'm hopping you know how to do.
HotNoob
100+ Club
 
Posts: 169
Joined: Sun May 02, 2010 1:38 am


Who is online

Users browsing this forum: No registered users and 2 guests