Passing session info to a popup
I have a report number that is generated from a page, and I want to display that number in a popup window upon a button click that saves the report to a database. On the original page, here's the code that I am trying to use:
Code:
Private Sub saverpt()
Dim url As String = "popup.aspx"
Dim s As String = "window.open('" & url + "', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');"
ClientScript.RegisterStartupScript(Me.GetType(), "script", s, True)
Session("rptnum") = rptnum.Text
On the popup.aspx page, here's what I am trying to make the rptnum field appear on:
Code:
Private Sub popup_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim rptnum As String = CType(Session.Item("rptnum"), String)
Label1.Text = rptnum.text
End Sub
Currently, the popup will display "rptnum" rather than the actual generated report number. What am I missing? Thanks in advance..
Re: Passing session info to a popup
Thread moved to ASP.NET forum, since that's what it appears to be.
Re: Passing session info to a popup
do strings work differently in ASP.NET? As far as I am aware, Strings don't have a .Text property... because the string IS the text... so I'm even sure that the code would even compile.
-tg
Re: Passing session info to a popup
Hi,
When using Session variables, make sure to add null checking/handling in your popup.aspx page.
Code:
If Session("rptnum") IsNot Nothing Then
Label1.text = DirectCast(Session("rptnum"), String)
End If
Regards,
KGC