Drag drop image from browser to form

A

Andreas Zita

Hello!

How can I get the image src url when dragging an image from a html-page (IE)
to a windows form?

I know how to get the url when dragging a href url using
data.GetDataPresent("UniformResourceLocator") etc but this isn't working
when dragging an image. I could encapsulate the image-tag with a anchor-tag
with the correct href to get the url but I can't use this method in my case.

When dragging a image without any encapsulating anchor-tag Internet Explorer
seems to dragdrop the entire image data(?) But how can I get the src url?

/Andreas Zita
 
M

Michael Powell

Hi Andreas,
try this, it should work to get the source URL for your picture
protected override void OnDragDrop(DragEventArgs drgevent)
{
if(CanCopy(drgevent) && drgevent.Data.GetDataPresent("FileDrop"))
{
string filename=((string [])drgevent.Data.GetData("FileDrop"))[0];
}
}
 
A

Andreas Zita

I can only get it to return the the local chached file path, not the
original url... ?

Thanks anyway!

/Andreas

Michael Powell said:
Hi Andreas,
try this, it should work to get the source URL for your picture
protected override void OnDragDrop(DragEventArgs drgevent)
{
if(CanCopy(drgevent) && drgevent.Data.GetDataPresent("FileDrop"))
{
string filename=((string [])drgevent.Data.GetData("FileDrop"))[0];
}
}

--
Mike Powell
Ramuseco Limited
www.ramuseco.com


Andreas Zita said:
Hello!

How can I get the image src url when dragging an image from a html-page
(IE) to a windows form?

I know how to get the url when dragging a href url using
data.GetDataPresent("UniformResourceLocator") etc but this isn't working
when dragging an image. I could encapsulate the image-tag with a
anchor-tag with the correct href to get the url but I can't use this
method in my case.

When dragging a image without any encapsulating anchor-tag Internet
Explorer seems to dragdrop the entire image data(?) But how can I get the
src url?

/Andreas Zita
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top