Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi guys am trying to copy the text to clipboard using javascript in ASP.net and C# but its working fine in local when host in IIS server its not working please help me to fix the issue Thank you . code written below like in the t there is data

What I have tried:

<pre lang="Javascript">
function copytoclipboard(t) {
  alert("t =" + t);
   const txt = t;
   navigator.clipboard.writeText(txt + 'xyz')
       .then(() => { alert(`Copied  123!`) })
       .catch((error) => { alert(`Copy failed! ${error}`) })
   return;
}
C# code 
<pre lang="c#">
CopyClipAction.Val = MacroDesc;
Thread newThread = new Thread(new ThreadStart(ClipActionPR));
newThread.SetApartmentState(ApartmentState.STA);
      newThread.Start();
Posted
Updated 16-Nov-20 22:22pm
Comments
F-ES Sitecore 17-Nov-20 7:01am    
Would you want websites reading your clipboard?

1 solution

The Javascript code uses the clipboard on the client. The C# code uses the clipboard on the server. And never the twain shall meet.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900