我有一个包含 7 个步骤的 asp:wizard - 在某一时刻,用户可以选择上传文件,或提供指向 Internet 上现有文件的链接。
在向导结束时,所有信息都会显示以供验证,每个部分都有按钮,以便他们可以返回并编辑某些内容(如果他们的名字拼写错误)。
在调试中,我发现如果我选择上传文件,它将一直保持到我到达表单的末尾,但如果我决定返回并编辑任何内容,则文件上传将消失。
我是否缺少一些东西来维持这一点,或者有可能吗?我会发布相关代码(有很多,它的形式很大)
在.aspx
<asp:WizardStep ID="uploadFileWiz" runat="server" Title="Upload File">
<!-- Step 4 - Upload a file -->
<table>
<tr>
<th colspan="2" class="alignCenter">
<%:uploadFileWiz.Title %>
</th>
</tr>
<tr>
<td class="alignRight">
File Location:
</td>
<td class="alignLeft">
<asp:FileUpload ID="uploadFile" runat="server" CssClass="inputBox" />
</td>
</tr>
<tr>
<td class="alignRight">
Is there a Password?
</td>
<td class="alignLeft">
<asp:RadioButtonList ID="uploadPasswordFlag" runat="server">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem Selected="True">No</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</table>
</asp:WizardStep>
............................................
<asp:WizardStep ID="grandFinale" runat="server" Title="Lets Finish Up">
<!-- Step 7 - The final step. Verify information -->
<div class="margins">
<span class="label">
Lets Review:
</span>
<table>
<tr>
<th class="alignRight">
Contact Name:
</th>
<td class="alignLeft">
<%:contactName.Text%>
</td>
<th class="alignRight">
Project Name:
</th>
<td class="alignLeft">
<%:projectName.Text%>
</td>
</tr>
<tr>
<th class="alignRight">
Contact Email:
</th>
<td class="alignLeft">
<%:contactEmail.Text%>
</td>
<th class="alignRight">
Project Location:
</th>
<td class="alignLeft">
<%:projectLocation.Text%>
</td>
</tr>
<tr>
<th class="alignRight">
Company:
</th>
<td class="alignLeft">
<%:contactCompany.Text%>
</td>
<th class="alignRight">
General Contractor:
</th>
<td class="alignLeft">
<%:projectContractor.Text%>
</td>
</tr>
<tr>
<th class="alignRight">
Phone Number:
</th>
<td class="alignLeft">
<%:contactPhone.Text%>
</td>
<th class="alignRight">
Bid Type:
</th>
<td class="alignLeft">
<%:bidType.SelectedValue%>
</td>
</tr>
<!-- Buttons to go back and edit, if needed -->
<tr>
<td colspan="2" class="alignCenter">
<asp:Button ID="goToContactInfo" runat="server" Text="Edit Contact Information" CssClass="inputBox" />
</td>
<td colspan="2" class="alignCenter">
<asp:Button ID="goToProjectInfo" runat="server" Text="Edit Project Information" CssClass="inputBox" />
</td>
</tr>
<tr>
<th class="alignRight">
File:
</th>
<td class="alignLeft">
<%:getFileInfo()%>
</td>
<th class="alignRight">
Password:
</th>
<td class="alignLeft">
<%:getPasswordInfo()%>
</td>
</tr>
<tr>
<td colspan="2" class="alignCenter">
<asp:Button ID="goToFileLink" runat="server" Text="Edit File Info" CssClass="inputBox" />
</td>
<td colspan="2" class="alignCenter">
<asp:Button ID="goToPassword" runat="server" Text="Edit Password" CssClass="inputBox" />
</td>
</tr>
</table>
</div>
</asp:WizardStep>
在代码隐藏中...
'##### Edit button handlers
Protected Sub goToContactInfo_Click(sender As Object, e As EventArgs) Handles goToContactInfo.Click
rqBidWizard.ActiveStepIndex = 0
End Sub
Protected Sub goToProjectInfo_Click(sender As Object, e As EventArgs) Handles goToProjectInfo.Click
rqBidWizard.ActiveStepIndex = 1
End Sub
Protected Sub goToFileLink_Click(sender As Object, e As EventArgs) Handles goToFileLink.Click
If selectFile.SelectedValue = "Attach File" Then
rqBidWizard.ActiveStepIndex = 4
Else
rqBidWizard.ActiveStepIndex = 5
End If
End Sub
Protected Sub goToPassword_Click(sender As Object, e As EventArgs) Handles goToPassword.Click
rqBidWizard.ActiveStepIndex = 6
End Sub
'##### String parsing functions
Protected Function getPasswordInfo() As String
Dim isPassword As Boolean = False
Dim thePassword As String = Nothing
If uploadPasswordFlag.SelectedValue = "Yes" Or LinkPasswordFlag.SelectedValue = "Yes" Then
isPassword = True
thePassword = password1.Text
End If
If isPassword Then
getPasswordInfo = "Yes: " & thePassword
Else
getPasswordInfo = "No"
End If
End Function
Protected Function getFileInfo() As String
Dim fileType As String = Nothing, fileName As String = Nothing, fileURL As String = Nothing
Select Case selectFile.SelectedValue
Case "Attach File"
fileType = "Uploaded"
If uploadFile.HasFile Then
fileName = IO.Path.GetFileName(uploadFile.PostedFile.FileName)
Else
fileName = "None"
End If
fileURL = Nothing
Case "Provide Link"
fileType = "Link"
fileName = Nothing
fileURL = Trim(provideLink.Text)
End Select
getFileInfo = fileType & ": "
If fileType = "Uploaded" Then
getFileInfo = getFileInfo & fileName
Else
getFileInfo = getFileInfo & fileURL
End If
End Function