|
Alternatively, you can use a File Upload control from the tool box in Iron Speed Designer.
Step 1: Drag and drop a File Upload control from the tool box in Iron Speed Designer. Bind the control by double clicking on the File Upload control and go to the Bindings tab in the Page Properties dialog.
Step 2: Drag and drop a Button control from the tool box in Iron Speed Designer. Double click the Button control to display Page Properties dialog and go to the Display tab. Enter the button text.
Step 3: Add the following button click event code in the Page class of your page to retrieve the file name of the uploaded file.
C#:
public MyPage()
{
this.Init += new System.EventHandler(MyInit);
}
public void MyInit(object sender, System.EventArgs e)
{
this.Button.Button.Click += new System.EventHandler(OnButton_Click);
}
private void OnButton_Click(object sender, System.EventArgs e)
{
string fileName = this.FileUpload.File.FileName;
fileName = fileName.Substring(fileName.LastIndexOf("\\") +1);
}
|
Visual Basic .NET:
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
AddHandler Button.Button.Click, AddressOf Me.OnButton_Click
End Sub
Private Sub OnButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim fileName As String = Me.FileUpload.File.FileName
fileName = fileName.Substring(fileName.LastIndexOf("\") + 1
End Sub
|
Note that FileUpload is the name of the File Upload control.
Step 4: Build and run your application.
|