ASP.NET - pasting an image on web form - Asked By Anjali agarwal on 28-Jan-10 11:20 PM

Hello,

I want to paste the images directly on the web form using Ctrl-V. Is it possible to do that. We have rich text box in our office, but rich text box does not allow to paste images directly, we have to upload them first.




any help willbe appreciated

Sakshi a replied to Anjali agarwal on 28-Jan-10 11:53 PM

a activex control which does pasting image is in the link,

http://www.codeproject.com/KB/graphics/ClipboardActiveX.aspx

also see this,

http://blogs.msdn.com/coding4fun/archive/2007/03/09/1848530.aspx


Thanks and Regards,
http://www.CodeCollege.NET
http://www.InterviewsGuru.info


Huggy Bear replied to Anjali agarwal on 29-Jan-10 12:33 AM
My doubt is whether you want to do this at run time or design time. In design time it is not possible for sure you should go about providing the ImageUrl for asp:Image and src for img tags. At runtime I think you should be able to use javascript to achieve it. http://forums.asp.net/t/1377332.aspx link would help.


mv ark replied to Anjali agarwal on 29-Jan-10 02:39 AM
Due to security reasons, browsers don't allow interaction with the file system. Hacks may exists for IE but there is no cross-browser way to achieve this
Anjali agarwal replied to Huggy Bear on 02-Feb-10 12:13 PM

Hi,

  Thanks for your reply. I am trying to paste the image at runtime. I wrote the code below, but I am not sure how will I invoke it from code behind.

Below is the front end code:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register TagPrefix="RTB" Namespace="RichTextBoxControl" Assembly="RichTextBox" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script language="javascript" type="text/javascript">

functiion test()

{

cursor_selection = document.getElementById('MessageTextBox').contentWindow.document.selection.createRange();

cursor_selection.execCommand('Paste');

}


</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<table>

<tr>

<td style="width: 323px">

<rtb:richtextbox id="MessageTextBox" runat="server" Width="1072px" Height="214px" ButtonType="Image"

HtmlOptionIsEnabled="False" ></rtb:richtextbox>

</td>

</tr>

</table>

</div>

</form>

</body>

</html>

In the back end, I don't have any code


using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

}