I ran into a strange case this evening.  Rendered text can not be copied to the clipboard after posting back a page containing an UpdatePanel. 

Here’s a simple use case:

  1. User enters client name and clicks button to request phone number.
  2. Page posts back and displays phone number.
  3. User selects the phone number, CTRL+C and attempted to CTRL+V into their contact list.
  4. User gets frustrated because the phone number was selectable but apparently could not be copied.

One might assume only the phone number can’t be copied.  Maybe the changing of the text and visible properties of the associated ASP:Label control is to blame.  Well, that’s not the case.  ALL text on the page can no longer be copied after the postback. 

Basically, add an UpdatePanel to a page, postback and you can’t copy anything to the clipboard.  By the way, I discovered the problem while using FireFox 2.0. I tested against IE 7 and I wasn’t able to duplicate the experience.

Try out the most simplistic example I could come up with below.  It might surprise you.

<%@ Page Language="C#" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:UpdateProgress ID="UpdateProgress1" runat="server">
        <ProgressTemplate>
            <img id="Img1" runat="server" src="AjaxIndicator.gif"/>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:ScriptManager ID="scriptManager" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="updatePanel" runat="server">
        <ContentTemplate>
        <asp:Label ID="message" runat="server">
            This is asp:Label text inside the update panel
                and it can be selected and copied only
                before the postback but not after.</asp:Label>
        <br />
        <br />
            This is regular text inside the update panel
                and it acts the same.
        <br />
        <br />
        <asp:Button ID="button" runat="server" Text="Go" />
        </ContentTemplate>
    </asp:UpdatePanel>

    This text is outside of the update panel and
    it acts the same as well.

    </form>
</body>
</html>

kick it on DotNetKicks.com

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>