Tricky Question: Page_Load

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • VB Programmer

    Tricky Question: Page_Load

    I have a usercontrol that sets a public/shared variable called
    "database_name" . (User selects a dropdownlist of available databases.) A
    webform (webform1), that uses this usercontrol, connects to the database
    defined by that public variable and does stuff.

    Problem: Webform1 is always one database "behind". This is because the
    Page_Load runs on webform1, THEN Page_Load is run on the usercontrol (which
    sets the database_name variable).

    Any ideas how I can fix this/compensate?

    Please assist.

    Thanks,
    Robert


  • charles

    #2
    Re: Tricky Question: Page_Load

    You could take the code out of page_load and put it into page_prerender.
    Then it will run after all your controls preload

    "VB Programmer" <growNO-SPAM@go-intech.com> wrote in message
    news:uSt4$czPDH A.1584@TK2MSFTN GP11.phx.gbl...[color=blue]
    > I have a usercontrol that sets a public/shared variable called
    > "database_name" . (User selects a dropdownlist of available databases.) A
    > webform (webform1), that uses this usercontrol, connects to the database
    > defined by that public variable and does stuff.
    >
    > Problem: Webform1 is always one database "behind". This is because the
    > Page_Load runs on webform1, THEN Page_Load is run on the usercontrol[/color]
    (which[color=blue]
    > sets the database_name variable).
    >
    > Any ideas how I can fix this/compensate?
    >
    > Please assist.
    >
    > Thanks,
    > Robert
    >
    >[/color]


    Comment

    • William F. Robertson, Jr.

      #3
      Re: Tricky Question: Page_Load

      You don't want to put any actually "processing " functionality into page
      load. You should be doing any processing in an event such as a click, that
      way all controls (both user and asp) have a chance to run their load event.
      The data for the controls in the page_load isn't guaranteed to be up to
      date.

      HTH,

      bill



      "VB Programmer" <growNO-SPAM@go-intech.com> wrote in message
      news:uSt4$czPDH A.1584@TK2MSFTN GP11.phx.gbl...[color=blue]
      > I have a usercontrol that sets a public/shared variable called
      > "database_name" . (User selects a dropdownlist of available databases.) A
      > webform (webform1), that uses this usercontrol, connects to the database
      > defined by that public variable and does stuff.
      >
      > Problem: Webform1 is always one database "behind". This is because the
      > Page_Load runs on webform1, THEN Page_Load is run on the usercontrol[/color]
      (which[color=blue]
      > sets the database_name variable).
      >
      > Any ideas how I can fix this/compensate?
      >
      > Please assist.
      >
      > Thanks,
      > Robert
      >
      >[/color]


      Comment

      • VB Programmer

        #4
        Re: Tricky Question: Page_Load

        This worked GREAT! Thanks!

        "charles" <charles@synthi gence.com> wrote in message
        news:eRriy3zPDH A.3664@tk2msftn gp13.phx.gbl...[color=blue]
        > You could take the code out of page_load and put it into page_prerender.
        > Then it will run after all your controls preload
        >
        > "VB Programmer" <growNO-SPAM@go-intech.com> wrote in message
        > news:uSt4$czPDH A.1584@TK2MSFTN GP11.phx.gbl...[color=green]
        > > I have a usercontrol that sets a public/shared variable called
        > > "database_name" . (User selects a dropdownlist of available databases.)[/color][/color]
        A[color=blue][color=green]
        > > webform (webform1), that uses this usercontrol, connects to the database
        > > defined by that public variable and does stuff.
        > >
        > > Problem: Webform1 is always one database "behind". This is because the
        > > Page_Load runs on webform1, THEN Page_Load is run on the usercontrol[/color]
        > (which[color=green]
        > > sets the database_name variable).
        > >
        > > Any ideas how I can fix this/compensate?
        > >
        > > Please assist.
        > >
        > > Thanks,
        > > Robert
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...