Results 1 to 4 of 4

Thread: Passing session info to a popup

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2014
    Posts
    35

    Cool 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..

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: Passing session info to a popup

    Thread moved to ASP.NET forum, since that's what it appears to be.
    My usual boring signature: Nothing

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    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
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width