|
-
Nov 12th, 2002, 10:48 AM
#1
Thread Starter
Frenzied Member
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.
-
Nov 12th, 2002, 11:42 AM
#2
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)
-
Nov 12th, 2002, 11:44 AM
#3
Thread Starter
Frenzied Member
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
-
Nov 12th, 2002, 11:51 AM
#4
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)
-
Nov 12th, 2002, 02:06 PM
#5
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|