C# mshtml.HTMLWindow2 execScript doesnt copy image RRS feed

  • Question

  • mshtml.HTMLWindow2 execScript doesnt copy image.


    w2.execScript("var ctrlRange = document.body.createControlRange();ctrlRange.add(document.getElementById('form').getElementsByTagName('IMG')[0]);ctrlRange.execCommand('Copy');", "javascript");

    System.Drawing.Image retImage = Clipboard.GetImage();

    retImage is null. 

    in html there is image

    • Edited by Soner CANOĞLU Thursday, March 8, 2018 5:43 PM i got error
    • Moved by Fei Hu Friday, March 9, 2018 8:40 AM ASP.NET related
    Thursday, March 8, 2018 3:13 PM

All replies

  • The WebBrowser control is for desktop applications. All browsers are the client portion of client/server applications.

    You don't specify how you tested it locally but you could not have gotten it to work if you tested it in a server such as the server provided by Visual Studio or a local instance of IIS.

    Sam Hobbs

    Thursday, March 8, 2018 6:58 PM
  • When i publish it any normal windows platforms it works. When i publish it win server 2012 r2 doesnt work

    Software Engineer

    Thursday, March 8, 2018 7:06 PM
  • I don't know how it is possible but this looks totally different from the question I replied to. The question I replied to was the same as many other questions; the same question was posted at least four times.

    Sam Hobbs

    Thursday, March 8, 2018 10:16 PM
  • Based on what this question said earlier, you are trying to use a WebBrowser in the server. It should not work in a server.

    Sam Hobbs

    Thursday, March 8, 2018 10:18 PM
  • Hello Soner,

    Your question is more related to office, you could repost a new thread to ASP.NET forum for professional support.

    The Visual C# discuss and ask the C# programming language, IDE, libraries, samples and tools. If you have some grammar or code errors, please feel free to contact us.

    Best Regards,

    Neil Hu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 9, 2018 8:39 AM