Partager via


What is Paste Alternate?

You may have noticed that both Design and Source views have Paste as well as Paste Alternate commands in the Edit menu. In VS 2003 and earlier versions Paste Alternate was called 'Paste As HTML' and almost no one understood how exactly it worked.

Why another paste command?

It comes from the fact that sometimes people want to paste <input type="button"> and sometimes they want &lt;input type="button"&gt; Imagine that you are reading some material on a Web site that explains how to construct a Web page and contains sample snippets of HTML.  You select one of the snippets in the browser and hit Edit | Copy. You then go to Visual Studio HTML editor and click Edit | Paste. What do you expect to get? It depends what view you are in.

In Source view you probably expect markup as it appears in the source Web page. This means VS has to convert CF_HTML that browser placed on Clipboard to a plain text so you'll get <div> and not &lt;div&gt; However, if you are in Design view, you probably expect same appearance as in the source Web page, so VS should paste CF_HTML unchanged.

Now, let's imagine that you are writing a tutorial on the Web page design and actually want to use snipped of HTML as illustration so you want Design view to display tags as text. That is when Paste Alternate comes handy. In Source view it converts markup to entities. In Design view it does the opposite and converts CF_HTML to plain text or plain text to CF_HTML.

Here is how Paste and Paste Alternate are supposed to work in different scenarios:

<b>b>

&lt;b&gt; hello world &lt;/b&gt;

Italic <b> b>

<font color=#0000ff> <i>Italic</i> &lt;b&gt; text &lt;/b&gt;

Note: the last line does not work correctly in Beta 1 or October Tech Preview, but we will fix it for Beta 2.

Comments

  • Anonymous
    November 07, 2004
    I believe that we can describe Paste Alternate more succinctly by calling it "Oops, that wasn't it -- let's try the other way." :)
  • Anonymous
    November 07, 2004
    You could use those smart tags like Word does to switch the once-pasted text to another format.
  • Anonymous
    November 08, 2004
    We wanted, but that was too expensive (time-wise) so we opted for this solution. We will defenitely consider smart tags (their VS incarnation) in Orcas.