locked
Paste Image From Clipboard RRS feed

  • Question

  • hi,

    how to paste the clipboard image to the web form using JavaScript or ASP.NET,

    I Pasted the Clipboard Text, but i failed to paste the image,

    i read article that Clipboard.GetData('Image') can get the image from clipboard but i cant able to get

    it,

    Temp is my Img Box id,

    [code]

    <html>
    <head>
    <script>
    function CopyToClip()
    {
    var div = document.getElementById('Temp');
    div.contentEditable = 'true';
    var cR;
    if (document.body.createControlRange)
    {
    cR = document.body.createControlRange();
    cR.addElement(div);
    cR.execCommand('Copy');
    }
    div.contentEditable = 'true';
    }
    function PasteToClip()
    {
    var div = document.getElementById('Temp');
    div.contentEditable = 'true';
    var cR;
    cImg = new Image (400,112);
    var cImg1;
    if (document.body.createControlRange)
    {
    cR = document.body.createControlRange();
    cR.addElement(div);
    cImg=cR.execCommand('Paste');

    if(cImg != null)
    {
    //Temp.src=cImg;
    document.getElementById('Temp').src=cImg;
    alert("Holding");

    }
    }
    div.contentEditable = 'true';
    }

    </script>
    </head>
    <body bgcolor="white">
    <div id="copythis">
    </div>
    <form>
    <div id="DivtoCopy">
    <img src="C:\JpgImg.jpg" id="Temp">
    </div>
    <input type="button" value="Copy2ClipBrd" onclick="CopyToClip()">
    <input type="button" value="Paste4rmClip" onclick="PasteToClip();">
    </form>
    </body>
    </html>

    [/code]

    which control can able to hold image other than image box,

    please help

    thanks in advance

    Wednesday, January 24, 2007 10:54 AM