Windows Control hosted in WebForm

M

Matt Theule

I need to be able to allow users to drag files to a list box on a web
page. To this end, I created a Windows Control and hosted it in a
WebForm. When the file is dropped onto the listbox, the path of the
file is truncated down to 8.3 format (with the ~1 at the end). When the
Windows control is hosted in a windows form (for testing purposes) the
full path is displayed.

Is there some setting that will allow the full path to be displayed when
hosted in a WebForm?

Alternatively, is there a different way to achieve the desired
functionality without using a WinForm control?

And less importantly, when hosted in an WebForm, the control is only
able to accept 1 file at a time. When hosted in a WinForm, the control
can accept multiple files. Any ideas?

Thanks

private void listBox1_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
e.Effect = DragDropEffects.None;
}

private void listBox1_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
try
{
string[] files = null;
if (e.Data.GetDataPresent(System.Windows.Forms.DataFormats.FileDrop))
{
files = (string[])e.Data.GetData("FileDrop", true);
}

foreach (string s in files)
{
listBox1.Items.Add(s);
}
}
catch (Exception exp)
{
System.Windows.Forms.MessageBox.Show(exp.Message);
}
}
 
M

Matt Theule

Thanks for the idea, but calling the API from the web hosted windows
control generated a ReflectionPermissions exception.

I did find that using the Framework wizard to adjust the .Net Security
allowed the full path to be shown without the use of the API. Although
everything at this point is on my development workstation, I had to
adjust the 'Local Intranet' zone to 'Full Trust'. The 'My Computer'
zone was defaulted to 'Full Trust'.

I had previously registered the windows control assembly as trusted, but
that did not make a difference.

Now I have to go figure out what is happening when the trust level is
adjusted.
 

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

Staff online

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top