Getting selected text values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having a problem. How can I get the selected text from a text editor.
I am using ASP.NET and VB as language.

Thanx
 
It's a client side function. Look at DHTML document.selection object. You
can get the selected text on the client and communicate it to the server in
a hidden text input.

Eliyahu
 
I've already used the DTE object and have coded the following lines into a
button click event:

' Get an instance of the currently running Visual Studio .NET IDE.
Dim dte As New EnvDTE.DTE
dte =
System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE")

'Get selected text
Dim objSel As TextSelection = dte.ActiveDocument.Selection

lblTest.Text = objSel.Text

however, i am getting the following error:

Exception Details: System.Runtime.InteropServices.COMException: COM object
with CLSID {3C9CFE1E-389F-4118-9FAD-365385190329} is either not valid or not
registered.

on the following line of code:

Dim dte As New EnvDTE.DTE

I hope that you can help me.

Thanx.
 
You are talking about Visual Studio text editor. Here we discuss ASP.NET and
I thought you were talking about selected text in an html control. You
should ask in a relevant newsgroup.

Eliyahu
 
I am sorry, I used the wrong object in my web application. I'll try to use
the DHTML documet.selection object and return to you later.

Thanks for your help.
 
Back
Top