473,769 Members | 6,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.redire ct) 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 3946
Please provide some examples :)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Goober" <go****@christi an.net> wrote in message
news:eX******** ******@TK2MSFTN GP10.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.redire ct) 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.Repla ce(":", ".")
Session("Calend ar") = objReader.GetDa teTime(4).ToStr ing
Session("ViewPr odHierSKUStatus ") = objReader.GetSt ring(8)
Session("ViewOl dSys") = objReader.GetSt ring(9)
Session("Permis sion") = objReader.GetSt ring(10)
Response.Cookie s("availability rptlevel").Valu e =
objReader.GetSt ring(11)
---> Session("availa bilityrptlevel" ) = objReader.GetSt ring(11)
TransactionLog( "")
Server.Transfer ("sales/newmenu.aspx?Us er=" &
objReader.GetSt ring(2) & "&Name=" & objReader.GetSt ring(3) & "&Sales=" &
sSales & "&Calendar= " & sCalendar & "&P=" & objReader.GetSt ring(6) &
"&Pass=" & objReader.GetSt ring(1) & "&Act=" & objReader.GetSt ring(7) &
"&SKUStat=" & Session("ViewPr odHierSKUStatus ") & "&Oldsys=" &
Session("ViewOl dSys") & "&Permissio n=" & Session("Permis sion"))
Here is the page load piece
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

If Request.QuerySt ring("User") = "" Then
lblUser.Text = Session("UserNa me")
End If

If Session("Sales" ) = "" Then
Session("Permis sion") = Request.QuerySt ring("P")
Session("Pass") = Request.QuerySt ring("Pass")
Session("UserNa me") = Request.QuerySt ring("Name")
Session("ActUse r") = Request.QuerySt ring("Act")
Session("User") = Request.QuerySt ring("User")
Session("Sales" ) = Request.QuerySt ring("Sales")
Session("Calend ar") = Request.QuerySt ring("Calendar" )
Session("Sales" ) = Session("Sales" ).replace("-", "/")
Session("Sales" ) = Session("Sales" ).replace(".", ":")
Session("Calend ar") = Session("Calend ar").replace( "-", "/")
Session("Calend ar") = Session("Calend ar").replace(". ", ":")
Session("ViewPr odHierSKUStatus ") =
Request.QuerySt ring("SKUStat")
Session("ViewOl dSys") = Request.QuerySt ring("Oldsys")
End If

If Session("UserNa me") = "" Then
Server.Transfer ("../Default.aspx")
End If
Session("ActUse r") = UCase(Session(" ActUser"))

Dim xxyz As String
--> xxyz = Session("availa bilityrptlevel" )

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.getst ring), 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****@christi an.net> wrote in message
news:eX******** ******@TK2MSFTN GP10.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.redire ct) 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****@christi an.net> wrote in message
news:eX******** ******@TK2MSFTN GP10.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.redi rect) 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.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

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

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

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Goober" <go****@christi an.net> wrote in message
news:en******** ******@TK2MSFTN GP10.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****@christi an.net> wrote in message
news:eX******** ******@TK2MSFTN GP10.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.redi rect) 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.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
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!1p4an4WFkHs QJSFZothKGsVA!1 13.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.redire ct) 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!1p5yU6ZZTd7 GExwiWD7vnCsg!1 06.entry

Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5005
by: Sam | last post by:
I have a custom control (MyTextBox - taken from Microsoft website) that implements the IPostBackDataHandler interface. It is added to the controls collection of a placeholder control during the Page Load of a main ASPX page. Now if we debug the MyTextBox, we find the order of events like so (during a Posback, of course): OnInit -> OnLoad -> LoadPostData. My question is why does the LoadPostData occur *after* the OnLoad instead of...
3
1626
by: markeboy | last post by:
I am wanting to control when a page is loaded using a separate class to manage when and how it should be loade My current implementation needs to set a property of the page programatically (through a defined interface on the page) I can create an instance of the code behind class (and interface) that the page inherits and implements, however, I have no way of then calling it to load Of course, this was quite possible in VB6, by...
3
1786
by: cmay | last post by:
In reading some documents from the Patterns and Practices group, I had a question about the example given for the Page Controller pattern. (I have posted the code for the BasePage below) In short, their example shows a "BasePage " class for other pages to inherit from. The subclasses are supposed to implement the PageLoadEvent method (which I guess should really be abstract, but can't because asp.net
5
1797
by: venky | last post by:
Hi, I have a question, i have a web control in my web page. Let say i have page pag1.aspx and control.ascx and page1 contains control. I have written code on the page load of page and also the control but page1 page load is never called. Is there any reason or any setting i need to do to ? venky
18
2152
by: J-T | last post by:
Hi All, There is a picture on the following URL which I want to have it in one of my asp.net pages .I mean I want to embed the content of this page in my own page and get its image.Is there a control or tecnique which I can accomplish this? http://www.tehrantraffic.com/gif.asp?g=cam3_ttcc_00001.jpg&t=TTCC%20website Thanks a lot
3
2888
by: Alex | last post by:
Sorry if this is not a correct forum to post to. I have a page from my service provider that loads 1000's of table cells. These cells load for 3-4 mins and links on that page usually not available untill the whole page loads. I need to find a way to "skip" load of these cells. Problem is that GreaseMonkey work only on a fully loaded page. What happens is that the page loads 3-4 mins and then the cells go away once the page loads and...
9
3191
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will load with different data (locations, departments, etc.).
2
4020
by: ricardo.sobral.santos | last post by:
Hello, I am trying to get the value of the radiobuttonlist. The problem is that I need it to be unselected at every page load. The radiobuttonlist is set to autopostback (true). My idea is simple. When I select a value, I get it, insert something into the database with that value and the page loads again with different data. Imagine a questionnaire and every page load a random question would be load on screen and when the user clicks...
5
7357
by: BerlinBrown | last post by:
Do you know if it is possible to wait for the iframe page to load and then manipulate the iframe DOM. E.g. mypage: <script> function myinit() { theiframe.location = "iframe_with_frames.html" waitforiframe() { theiframe.frames.location ="mynewpage3.html";
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7409
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.