Results 1 to 2 of 2

Thread: [RESOLVED] Having trouble running code when loading a Second ASP.Net page

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    523

    Resolved [RESOLVED] Having trouble running code when loading a Second ASP.Net page

    Using ASP.net VB
    I want to build and display Page2.asp when I click a button on Page1.asp.

    I have my main ASP.net page, and when I click a button I run the following code:
    Code:
            Dim filename as string = "Page2.asp"
            Dim redirect As String = "<script>window.open('" & filename & "');</script>"
            Response.Write(redirect)
    When I Load Page2 I want to run some initialization code. I placed this in a subroutine called Initialize, and put a breakpoint on the subroutine call. The code behind file is:

    Code:
    Public Class Page2
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
           Initialize()
        End Sub
    
          Sub Initialize()
            ' a bunch of code
         end Sub
    end Class
    The initialization code is populating a chart with data from Page1. The code never breaks on Initialize statement in the the Page_Load. What am I doing wrong? How do I trigger the Initialize code?

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    523

    Re: Having trouble running code when loading a Second ASP.Net page

    I solved my problem. The above code does appear to work. I was erroneously overwriting the Page2.asp file in code, which appears to cause the Page_load not to fire. Once I removed the code to overwrite the file, the above code worked fine.

    I marked this as solved (although it was not a real issue - just an oversight on my part).

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