如何使用ASP.NET C#或使用javascript从弹出页面复制内容 [英] How to copy content from popup page using ASP.NET C# or using javascript

查看:69
本文介绍了如何使用ASP.NET C#或使用javascript从弹出页面复制内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想从弹出页面复制内容(弹出页面是aspx页面。)我的要求是需要在弹出页面上添加一个按钮 。当我们点击该按钮(COPY)时,所有内容都应该使用ASP.NET C#或Javascript进行复制(对于内容标签使用)。



这是我的代码这是有效的。但是我的代码中存在一个问题。如何通过单击按钮(复制)内容来实现此目的应该复制。



它现在正在运行。但是我在测试我的应用程序后发现了一个问题。



问题是,我在gridview中的每一行都有图标。如果我点击图标,它显示为弹出窗口(实际上它不是一个弹出窗口,添加为新页面)。我的疑问是,如果我第一次点击任何行上的COPY按钮,它的复制内容。但是第二次点击gridview内不同行中的COPY按钮时,它不会复制其他内容。它复制了我之前复制的旧内容。



如何解决这个问题,点击任意行中任何图标上的COPY按钮,而不是将内容数据排成行的副本预览/第一次复制数据/内容。

Hi,

I want to copy content from popup page(popup page is aspx page.) My requirement is need add one "Button" on that popup page . When we will click on that button(COPY), All content should copy(For contents Label is used) using ASP.NET C# or Javascript.

Here is my code which is working. But there is one problem in my code. How to achieve this by clicking on Button(Copy) content should copy .

It is working now. But there is one problem i found after testing my application.

Problem is that, I have icons in each row inside gridview . If i clicked on icon, its showing as like popup(Actually its not a popup window, Added as new page). My doubt is, if first time i clicked on COPY button on any rows, its able copy content .But second time while clicking on COPY button in different rows inside gridview, its not copying other content. Its copying old content which i copied earlier.

How to fix this issue, While click on COPY button on any icon in any rows, its copy that rows content data instead of previews/first time copy data/content.

<pre><input type="button" id="btnCopy"  value="Copy" onclick="window.clipboardData.setData('text', document.getElementById('ltlContentName').innerText);" />





我的尝试:



我试过上面的代码。



What I have tried:

I tried above code.

<input type="button" id="btnCopy"  value="Copy" onclick="window.clipboardData.setData('text', document.getElementById('ltlTemplateName').innerText);" />

推荐答案

使用以下功能:

Use following function:
function copyToClipboard(sID) {
        var aField = document.getElementById("hiddenField");

        aField.hidden   = false;
        aField.value    = document.getElementById(sID).textContent;
        aField.select();
        document.execCommand("copy");
        alert("Following text has been copied to the clipboard.\n\n" + aField.value);
        aField.hidden = true;
    }





访问此链接了解更多信息

如何在JavaScript中复制到剪贴板? - 堆栈溢出 [ ^ ]


这篇关于如何使用ASP.NET C#或使用javascript从弹出页面复制内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆