0

我有一个包含 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
4

1 回答 1

0

如果您的意思是在某个向导步骤上,用户使用文件上传控件来选择文件,但是当他们进一步前进然后返回时,文件上传控件为空......我很抱歉地说这就是文件上传控件的工作方式。

每次更改向导步骤时,您都会发回并重新加载页面。所以用户提供的内容就丢失了。您可能认为您可以在服务器上以编程方式设置控件的文件名,但这不起作用——这是正确的,因为这将是一个很大的安全漏洞。(您希望如何浏览到可以决定要上传哪些文件的网页?)

您可能需要稍微重新组织您的向导才能解决此问题。

于 2013-03-05T03:28:51.047 回答