Is This Even Possible?

  • Thread starter Thread starter David Krussow
  • Start date Start date
D

David Krussow

In a C#/code-behind ASP.NET application, I want to enable the user to view a
few paragraphs. I want to enable the user to select a sentence (or an
individual word) within the paragraph. By *select* I mean that the user
clicks and drags over the word(s) to be selected - just like in any other
application that allows the user to select text. After selecting the desired
text, I want to enable the users to click a button - at which point some
code runs that ultimately results in the selected text (and not any of the
unselected text) being saved to a database.

I can do practically all of this. The part I'm hung up on is
programmatically determining which text the user selected within the
paragraph. Is that even possibe? If so, how?

Thanks in advance.
 
David said:
In a C#/code-behind ASP.NET application, I want to enable the user to
view a few paragraphs. I want to enable the user to select a sentence
(or an individual word) within the paragraph. By *select* I mean that
the user clicks and drags over the word(s) to be selected - just like
in any other application that allows the user to select text. After
selecting the desired text, I want to enable the users to click a
button - at which point some code runs that ultimately results in the
selected text (and not any of the unselected text) being saved to a
database.

I can do practically all of this. The part I'm hung up on is
programmatically determining which text the user selected within the
paragraph. Is that even possibe? If so, how?

Thanks in advance.

It's possible if you use Javascript + populating hidden fields that you
access on postback. I can't tell you what kind of Javascript event handling
you would need to detect the begin/end selection points. But that's the
solution I believe.
 
Do you have the options of Java or ActiveX? I think that's the only way to
get the selected text. I don't know of any javascript that will give you
the selected text in a textbox or outside of a text box.

http://www.javascripts.com might have a javascript solution.

Michael
 
Back
Top