Jeffery,
The editor is part of a larger application I am building...If the following
information does not help you understand my problem I will try to create a
standalone version to reproduce the problem.
I have created an Editor using the WebBrowser component
A section within the document contains the following HTML
<P><A href="http://test.com">testing</A></P>
<P> </P>
In the editor I highlight the link (the word testing)
The following code then executes
Dim Doc As mshtml.IHTMLDocument2 =
DirectCast(Web.Document.DomDocument, mshtml.IHTMLDocument2)
Dim oSelection As mshtml.IHTMLSelectionObject = Doc.Selection
Dim oDocLink As mshtml.HTMLAnchorElementClass = Nothing
Dim oControlRange As mshtml.IHTMLControlRange = Nothing
Dim oTxtRange As mshtml.IHTMLTxtRange = Nothing
Dim sHTMLText As String = ""
oTxtRange = DirectCast(oSelection.createRange(), mshtml.IHTMLTxtRange)
'I'm not setting these..I'm showing you the value for each of the
properties. These values are as expected.
'oTextRange.text="testing"
'oTextRange.HTMLtext="<A href="http://test.com">testing</A>"
'As you can see from the text below that All I am doing is pasting back
exactly the same HTMLtext I got from the Selection object..
sHTMLText = oTxtRange.htmlText
oTxtRange.pasteHTML(sHTMLText)
Return
what is returned in the HTML Doc is:
<P><A href="http://test.com">testing</A><A href="http://test.com"></A></P>
<P> </P>
as you can see, the link tag is duplicated but with no text between the <A>
and </A>.
Now if I pass just a piece of text to the PasteHTML function like
oTxtRange.pasteHTML("New Link")
then I get
<P><A href="http://test.com">New Link</A></P>
<P> </P>
In this case, no duplicate...
My only option at this time is to simple execute
oTxtRange = DirectCast(oSelection.createRange(), mshtml.IHTMLTxtRange)
oTxtRange.execCommand("CreateLink", True, Nothing)
instead of using my own code to do the updating. I really don't want to use
this because the default Hyperlink dialog does not allow me to update any
other attributes of the tag like class or style etc...
Is there a bug here in mshtml?? or am I mis-understanding the way pasteHTML
works?
Again if you are unable to understand my problem then I will try and put
together a small app to show you the problem..
Thanks
Jason
[quoted text, click to view] ""Jeffrey Tan[MSFT]"" wrote:
> Hi Jason,
>
> Thanks for your post!
>
> Can you provide a little sample project to demonstrate the problem? It will
> be helpful to the understanding. Also, you'd better post the details steps
> to reproduce the problem.
>
> Thanks
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Community Support
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
>