【问题标题】:Public ReadOnly Property from PreviousPage returns 'nothing'PreviousPage 中的 Public ReadOnly 属性返回“无”
【发布时间】:2015-08-27 06:31:18
【问题描述】:

我有一个公共只读属性 BatchInvoice 作为字符串,我在下一页使用 PreviousPage 读取它。我设置的其他属性工作正常。只是这个不返回任何内容的字符串。

这是我的代码。

Private _sBatchInvoice As String

Public ReadOnly Property BatchInvoice As String
    Get
        Return _sBatchInvoice
    End Get
End Property

_sBatchInvoice is populated from an AsyncFileUploadEventArgs.

Protected Sub BatchUploader_UploadedComplete(sender As Object, e As AjaxControlToolkit.AsyncFileUploadEventArgs)
    Dim sArrayList As String()

    With class1
        If uplBatchFile.HasFile Then
            System.Threading.Thread.Sleep(500)

            Dim savePath As String = MapPath(IO.Path.Combine("~/Temp", System.IO.Path.GetFileName(uplBatchFile.FileName)))
            uplBatchFile.SaveAs(savePath)
            sArrayList = .GetBatchUpload(uplBatchFile.FileName)
            Dim i As Integer

            For i = 0 To sArrayList.Length - 1
                _sBatchInvoice = _sBatchInvoice & "'" & sArrayList(i).ToString() & "',"
            Next

            'remove last comma
            _sBatchInvoice = _sBatchInvoice.TrimEnd(CChar(","))
        End If
    End With


End Sub

在下一页上,我通过以下方式访问 BatchInvoice:

Public sInvoiceList as String

With PreviousPage  
sInvoiceList = .BatchInvoice '-- this returns 'Nothing'  
End With

我可能错过了什么?

提前致谢! 乔尔

【问题讨论】:

  • 网络表单? MVC?为您的问题添加适当的标签。
  • PreviousPage 来自哪里?
  • 嗨@Sam。这是一种 MVCish 方法。它使用带有 JSRender 的网络表单。
  • 嗨@Matt,代码的第一部分来自上一页。当我从当前页面的上一页访问属性 BatchInvoice 时,它​​什么也不返回。希望我正确回答了您的问题。
  • PreviousPage是什么Object,在哪里设置?如果您使用 WebForms,我怀疑您的 _sBatchInvoice 变量在回发时会被清除,但如果没有更多代码,很难猜测

标签: vb.net webforms jsrender


【解决方案1】:

对此我深表歉意。

出于某种原因,我在上一页设置的公共只读属性在 AsyncFileUploader UploadedComplete 事件之后被清除。我更换了控件,它现在可以工作了。谢谢!

乔尔

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-23
    • 1970-01-01
    • 2020-11-07
    • 2019-12-11
    • 2020-01-24
    • 2020-11-29
    • 1970-01-01
    相关资源
    最近更新 更多