Getting selected text values

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
 
E

Eliyahu Goldin

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
 
G

Guest

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.
 
E

Eliyahu Goldin

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top