469,945 Members | 2,306 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

Page load question

I have a page that receives a session variable from the default.aspx.
On Page load, the code in Page load gets executed twice. So far, no
problem. It sets the session variable each time, correctly.

However, when I click on a menu item in that page, it then executes the
same page load twice, before transferring control (via a
response.redirect) to the new page. On the first pass through the page
load of the menu page, the session variable appears to be set to
nothing, when at the end of the first page load it was set properly.
What's happening with this code? I can provide some examples if needed.

BC
Nov 18 '05 #1
7 3820
Please provide some examples :)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Goober" <go****@christian.net> wrote in message
news:eX**************@TK2MSFTNGP10.phx.gbl...
I have a page that receives a session variable from the default.aspx.
On Page load, the code in Page load gets executed twice. So far, no
problem. It sets the session variable each time, correctly.

However, when I click on a menu item in that page, it then executes the
same page load twice, before transferring control (via a
response.redirect) to the new page. On the first pass through the page
load of the menu page, the session variable appears to be set to
nothing, when at the end of the first page load it was set properly.
What's happening with this code? I can provide some examples if needed.

BC

Nov 18 '05 #2
Karl Seguin wrote:
Please provide some examples :)

Karl

Here you are:

Here's where it gets set in the default.aspx.vb section

sCalendar = sCalendar.Replace(":", ".")
Session("Calendar") = objReader.GetDateTime(4).ToString
Session("ViewProdHierSKUStatus") = objReader.GetString(8)
Session("ViewOldSys") = objReader.GetString(9)
Session("Permission") = objReader.GetString(10)
Response.Cookies("availabilityrptlevel").Value =
objReader.GetString(11)
---> Session("availabilityrptlevel") = objReader.GetString(11)
TransactionLog("")
Server.Transfer("sales/newmenu.aspx?User=" &
objReader.GetString(2) & "&Name=" & objReader.GetString(3) & "&Sales=" &
sSales & "&Calendar=" & sCalendar & "&P=" & objReader.GetString(6) &
"&Pass=" & objReader.GetString(1) & "&Act=" & objReader.GetString(7) &
"&SKUStat=" & Session("ViewProdHierSKUStatus") & "&Oldsys=" &
Session("ViewOldSys") & "&Permission=" & Session("Permission"))
Here is the page load piece
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Request.QueryString("User") = "" Then
lblUser.Text = Session("UserName")
End If

If Session("Sales") = "" Then
Session("Permission") = Request.QueryString("P")
Session("Pass") = Request.QueryString("Pass")
Session("UserName") = Request.QueryString("Name")
Session("ActUser") = Request.QueryString("Act")
Session("User") = Request.QueryString("User")
Session("Sales") = Request.QueryString("Sales")
Session("Calendar") = Request.QueryString("Calendar")
Session("Sales") = Session("Sales").replace("-", "/")
Session("Sales") = Session("Sales").replace(".", ":")
Session("Calendar") = Session("Calendar").replace("-", "/")
Session("Calendar") = Session("Calendar").replace(".", ":")
Session("ViewProdHierSKUStatus") =
Request.QueryString("SKUStat")
Session("ViewOldSys") = Request.QueryString("Oldsys")
End If

If Session("UserName") = "" Then
Server.Transfer("../Default.aspx")
End If
Session("ActUser") = UCase(Session("ActUser"))

Dim xxyz As String
--> xxyz = Session("availabilityrptlevel")

the above setting it equal to a string is just some test code I put in
to make sure it was getting set in this code, and was picking up the
right info in it.
When it get set = to "04" in the first part of the code (at the
objreader.getstring), it is set, and then gets passed into newmenu.aspx.

When it hits newmenu.aspx, it runs thru this code twice (below the xxyz
is just some stuff it does with which menu items show up for which
users). When the page loads, it is still set to "04". However, when I
click on the menu item, it hits page load again, and it sets the session
variable = to nothing.
Nov 18 '05 #3
the most common cause for this is you actually assign the onload handler
twice, look in oninit section.
"Goober" <go****@christian.net> wrote in message
news:eX**************@TK2MSFTNGP10.phx.gbl...
I have a page that receives a session variable from the default.aspx.
On Page load, the code in Page load gets executed twice. So far, no
problem. It sets the session variable each time, correctly.

However, when I click on a menu item in that page, it then executes the
same page load twice, before transferring control (via a
response.redirect) to the new page. On the first pass through the page
load of the menu page, the session variable appears to be set to
nothing, when at the end of the first page load it was set properly.
What's happening with this code? I can provide some examples if needed.

BC

Nov 18 '05 #4
bruce barker wrote:
the most common cause for this is you actually assign the onload handler
twice, look in oninit section.
"Goober" <go****@christian.net> wrote in message
news:eX**************@TK2MSFTNGP10.phx.gbl...
I have a page that receives a session variable from the default.aspx.
On Page load, the code in Page load gets executed twice. So far, no
problem. It sets the session variable each time, correctly.

However, when I click on a menu item in that page, it then executes the
same page load twice, before transferring control (via a
response.redirect) to the new page. On the first pass through the page
load of the menu page, the session variable appears to be set to
nothing, when at the end of the first page load it was set properly.
What's happening with this code? I can provide some examples if needed.

BC


This is the code that is immediately prior to the page load. Do not see
where I'm calling it twice.

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
Nov 18 '05 #5
Make sure you aren't hookup up the event in InitializeComponent() as well as
setting AutoEventWireup to true in the aspx @Page directive.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Goober" <go****@christian.net> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
bruce barker wrote:
the most common cause for this is you actually assign the onload handler
twice, look in oninit section.
"Goober" <go****@christian.net> wrote in message
news:eX**************@TK2MSFTNGP10.phx.gbl...
I have a page that receives a session variable from the default.aspx.
On Page load, the code in Page load gets executed twice. So far, no
problem. It sets the session variable each time, correctly.

However, when I click on a menu item in that page, it then executes the
same page load twice, before transferring control (via a
response.redirect) to the new page. On the first pass through the page
load of the menu page, the session variable appears to be set to
nothing, when at the end of the first page load it was set properly.
What's happening with this code? I can provide some examples if needed.

BC


This is the code that is immediately prior to the page load. Do not see
where I'm calling it twice.

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Nov 18 '05 #6
If the page you have described is set as the "default document" in IIS for
this folder, there can be another reason for the double loading of the page:

if you have on the page somthing like <img src=''>, than IE thinks that the
source of the image is the current path, which is your current directory.
IIS will translate this and will think the browser asked for the default
document - which is your page !!!

See the following link for more detailed explanation
http://spaces.msn.com/members/jon-spcae/Blog/cns!1p4an4WFkHsQJSFZothKGsVA!113.entry
"Goober" wrote:
I have a page that receives a session variable from the default.aspx.
On Page load, the code in Page load gets executed twice. So far, no
problem. It sets the session variable each time, correctly.

However, when I click on a menu item in that page, it then executes the
same page load twice, before transferring control (via a
response.redirect) to the new page. On the first pass through the page
load of the menu page, the session variable appears to be set to
nothing, when at the end of the first page load it was set properly.
What's happening with this code? I can provide some examples if needed.

BC

Nov 19 '05 #7
The link wasn't right. Here is a working one:

http://spaces.msn.com/members/jon-space/Blog/cns!1p5yU6ZZTd7GExwiWD7vnCsg!106.entry

Nov 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by markeboy | last post: by
5 posts views Thread by venky | last post: by
18 posts views Thread by J-T | last post: by
3 posts views Thread by Alex | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.