2

CSSを無効にすると機能することに気づきました。誰か理由を説明できますか?

テキストボックスの値をクリップボードにコピーするためにゼロクリップボードに取り組んでいます。

通常の HTML ページで動作させることはできますが、同じコードを aspx ページに適用すると、意図したとおりに動作しません。

最初に、通常の html ページでどのように機能するかを説明しましょう。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Locker.test" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

</head>
<body>
    <form id="form1" runat="server">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
     <asp:Button ID="Button1" runat="server" Text="Button" />      
    </form>

             <script type="text/javascript" src="Scripts/jquery-1.9.1.js"></script>
             <script type="text/javascript" src="Scripts/jquery.zclip.js"></script>
             <script type="text/javascript" src="Scripts/jquery.zclip.min.js"></script>
              <script>
                  $(document).ready(function () {
                      $('#<%=Button1.ClientID%>').zclip({
                          path: 'ZeroClipboard.swf',
                          copy: function () { return $('#<%=TextBox1.ClientID%>').val(); }
                      });
                  });
              </script>
</body>
</html>

テキストボックスに入力されたものは何でもクリップボードにコピーします。

ボタンを右クリックすると、Zeroclipboard フラッシュに接続されていることがわかります。 ここに画像の説明を入力

マスターページにリンクされているaspxページに同じものを実装すると、機能しません。

zerocliboard が初期化されていないと思います。

ボタンを右クリックすると、別のものが表示されます。(これを機能させるには、上記のようにする必要があります。)

ここに画像の説明を入力

aspx ページのコードは次のとおりです。

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="searchResult.aspx.cs" Inherits="Locker.searchResult" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .auto-style1 {
            color: #FFFFFF;
            font-size: large;
        }
        .auto-style2 {
            color: #000000;
        }
        .auto-style3 {
            color: #000000;
            font-size: large;
        }
    </style>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">

        &nbsp;<p>

        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong> <span class="auto-style3">Information</span><span class="auto-style1">&nbsp;&nbsp;&nbsp;</span></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
         <div style="width:70%; margin: auto auto; text-align:left;">
          <asp:Panel ID="Panel1" runat="server">
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:Label ID="Label4" runat="server" style="font-weight: 700; font-size: large" Text="Details for :" CssClass="auto-style2"></asp:Label>
            <asp:Label ID="Label5" runat="server" style="font-weight: 700; font-size: large; color: #0000FF"></asp:Label>
            <br />
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:Label ID="Label1" runat="server" Font-Bold="False" style="font-weight: 700; font-size: large" Text="Password :" CssClass="auto-style2"></asp:Label>
            &nbsp;<asp:TextBox ID="TextBox2" runat="server" BorderStyle="Solid"  Enabled="False" Font-Size="Medium" ForeColor="Black" Width="213px"></asp:TextBox>

              &nbsp;

              <asp:Button ID="Button3" runat="server" Text="Button" />              
              <input type="text" id="test_description" value="hi" />

             <script type="text/javascript" src="Scripts/jquery-1.9.1.js"></script>
             <script type="text/javascript" src="Scripts/jquery.zclip.js"></script>
             <script type="text/javascript" src="Scripts/jquery.zclip.min.js"></script>
              <script>
                 window.onload = $(document).ready(function () {
                      $('#<%=Button3.ClientID%>').zclip({
                          path: 'ZeroClipboard.swf',
                          copy: window.onload = function () { return $('#<%=TextBox2.ClientID%>').val(); }
                      });
                  });
              </script>
            <br />
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
            <asp:Label ID="Label6" runat="server" style="font-weight: 700; font-size: large" Text="Description :" CssClass="auto-style2"></asp:Label>
            &nbsp;<asp:TextBox ID="TextBox5" runat="server" BorderStyle="Solid" Enabled="False" Font-Size="Medium" Height="48px" TextMode="MultiLine" Width="213px"></asp:TextBox>
            <br />
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Label ID="Label7" runat="server" style="font-weight: 700; font-size: small" Text="Last Editor was " CssClass="auto-style2"></asp:Label>
            <asp:Label ID="Label8" runat="server" style="font-weight: 700; font-size: small" CssClass="auto-style2"></asp:Label>
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Edit" Width="97px" />
            <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Update" Visible="False" Width="97px" />
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Label ID="Label12" runat="server" style="font-weight: 700; font-size: large; color: #0000FF" Visible="False"></asp:Label>
            <br />
            <br />
            <br />
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp;
    </asp:Panel>

         </div>
</asp:Content>

誰が問題が何であるかを知っていますか?これをどのように修正できますか?

HTML ページから結果を検査する ここに画像の説明を入力

通常のページから結果を検査 ここに画像の説明を入力

4

1 に答える 1

1

「Inspect Result from Normal Page」の出力を見ると、「TextBox2」が無効になっていることがわかり (有効にする必要があります)、CSS クラス「aspNetDisabled」も適用されています。CSS をオフにすると機能が動作するため、ZeroCopy 機能が失敗する原因となっているのは「aspNetDisabled」クラスである可能性が最も高いです。

「HTML ページから結果を検査する」の「TextBox1」が無効になっていないことに注意してください。

したがって、これを機能させるには、ASPX ページの「TextBox2」で「有効」が True に設定されていることを確認してください。

また、ZeroClipboard は「目に見えない Adob​​e Flash ムービー」を使用するため、これを使用するブラウザーに Flash がインストールされていることを確認してください。

最後に、「window.onload」を削除します。つまり、コードを次のように変更します。

$(document).ready(function () {
 $('#<%=Button3.ClientID%>').zclip({
  path: 'ZeroClipboard.swf',
  copy: function () { return $('#<%=TextBox2.ClientID%>').val(); }
 });
});

ZeroClipboard ライブラリでは動作しないと思います。

于 2013-10-04T22:32:16.517 に答える