Stupid question I know but how do i create one? All i need it to do is open up a dialog box and populate the text box next to it
how to create a file upload button in silverlight
481 views Asked by ivordesign At
2
There are 2 answers
0
On
If I understand correctly you are asking only about putting a user-selected filename into a TextBox control next to a button. You are NOT asking about the actual uploading of the file. If this is correct, then my answer is that you can do this:
OpenFileDialog dlg = new OpenFileDialog();
dlg.Multiselect = false;
if (dlg.ShowDialog() == true)
{
yourTextBox.Text = dlg.File.Name;
// Read stream of data from file, etc.
}
You can't show the full path which would have been available via dlg.File.FullName due to security restrictions in Silverlight.
You need to use the
OpenFileDialog
(silverlight 2.0). There are plenty examples kicking around or I am a big fan of Video Demo's example 2.