【发布时间】:2011-09-05 16:31:33
【问题描述】:
我正在尝试消除我的 aspx 页面上的 VB.NET 按钮。尝试使用 javascript 和 ajax 来执行我的 vb 的相同代码。
我放入了一个脚本管理器,将 EnablePageMethods 设置为 true,添加了一个静态子例程,并在我的 javascript 函数中引用它(顺便说一句,这似乎只是为了执行现有的子例程需要做很多工作)。 javascript 调用我的代码隐藏,它几乎可以工作。
问题是,现在当 SimulatePrintBatchClick 尝试对控件执行任何操作时,我得到了 NullReferenceException。
错误是'对象引用未设置为对象的实例',行是'pnlVars.Controls.Clear'
这是来自 UW.aspx 的代码:
<WebMethod()> _
Public Shared Sub PrintBatchFromJSWM()
Dim UWI As New UW
UWI.SimulatePrintBatchClick()
End Sub
Sub SimulatePrintBatchClick()
Dim Client As New LetterWriterClient
'Run ExStream and get the PDF File
Globals.PDF_Data = Nothing
Globals.PDF_Data = Client.ProcessDatFile(Session("SessionID").ToString)
'Reload the form -- turn off all controls, initialize variables and make the PDF iFrame visible
pnlVars.Controls.Clear() 'Bombs out on THIS line of code
pnlPDF.Visible = True
Me.SendToBach.Visible = False
Session.Contents("LetterVariables") = Nothing
Session.Contents("PolicyInformation") = Nothing
Session.Contents("Submitted") = True
Response.Redirect("UW.aspx")
End Sub
有趣的是,当我在 PrintBatch_Click 中运行上述代码时,一切都执行得很好。我真的不明白为什么它作为一个子程序会爆炸。
也许这不是执行此操作的方法,但我无法找到其他方法。最初此代码由 ASP/VB 按钮处理,但规范要求将其删除。
有什么方法可以让上面的代码完成它的工作?
谢谢, 杰森
【问题讨论】:
标签: asp.net ajax vb.net webmethod