Results 1 to 5 of 5

Thread: Page Load event firing twice??[RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    Page Load event firing twice??[RESOLVED]

    I have this code in my CodeBehindPage in the Page_Load event to populate my DropDownList, but it populates the DropDown twice. I debugged and it does indeed go through the code twice. Anyone come across this issue? Any solutions?

    If Not Me.IsPostBack() Then
    Me.DropDownList1.Items.Add(New ListItem("WEBDDEVL1"))
    Me.DropDownList1.Items.Add(New ListItem("WEBDDEVL2"))
    Me.DropDownList1.Items.Add(New ListItem("WEBDDEVL3"))
    End If
    Last edited by EyeTalion; Nov 12th, 2002 at 02:07 PM.

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Post the entire page load event, please.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    not much in there beside the code to fill the dropDown...


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here

    If Not Me.IsPostBack() Then
    Me.DropDownList1.Items.Add(New ListItem("WEBDDEVL1"))
    Me.DropDownList1.Items.Add(New ListItem("WEBDDEVL2"))
    Me.DropDownList1.Items.Add(New ListItem("WEBDDEVL3"))
    End If


    End Sub

  4. #4
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    There has to be an external reason the page load is firing twice. This is not usual behaviour and the code you have there would not cause it to happen.

    First, since you have 'Handles myBase.Load' on your page, did you also set AutoEventWireup to false on the @Page directive? It's entirely possible that is causing it if you did not.

    If worse comes to worse, you can check the length of the combo box and if it has more than 1 item, bail out of the sub right away, but I have a suspicion that something else references that page load.

    Since you already have 'Handles myBase.Load' on that function, try renaming it and run your page again. Make sure that the @Page directive has AutoEventWireup = false if you do this. (That stops it from assuming what the loading proceedures are)
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  5. #5

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    It was the AutoEventWireup, I had it deleted out of the page directive.

    thanks Lord

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