473,385 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ASP.NET C#: Page_Load executes on post back of other page

115 100+
Ok..so the title doesnt make much sense. Here is the problem: I have one page, that when loaded checks a session variable to determine that the user is allowed to view the page before sending the contents. On this same page there is a "Log Out" button which is an anchor tag that points back to the login page where it logs out and clears the session.

So now the client is back at the log on page. Clicks log in and the Page_Load event of the page the user came from fires looking for that session variable thus causing an error due to the cleared session which would be initialized on the log in click. WHY!? Were done with that page!

What am I missing here? Why is there a call to the previous page?
Sep 5 '08 #1
5 3431
nateraaaa
663 Expert 512MB
Posting code would be helpful.

Nathan
Sep 8 '08 #2
Frinavale
9,735 Expert Mod 8TB

So now the client is back at the log on page. Clicks log in and the Page_Load event of the page the user came from fires looking for that session variable thus causing an error due to the cleared session which would be initialized on the log in click. WHY!? Were done with that page!
I don't understand what you are trying to do.

What is the error you are getting?

Are you by any chance using Server.Transfer?

-Frinny
Sep 8 '08 #3
Plater
7,872 Expert 4TB
Is the redirection of your "Log Out" button handled on the server side? Or is the button marked as runat="server".
I have seen some odd behavior where the page_load() would get fired because the button is marked as runat="server", even though it's redirecting through javascript and such?
Sep 8 '08 #4
ShadowLocke
115 100+
Is the redirection of your "Log Out" button handled on the server side? Or is the button marked as runat="server".
I have seen some odd behavior where the page_load() would get fired because the button is marked as runat="server", even though it's redirecting through javascript and such?
The redirect is client side. The runat tag i thought would have been it. But this is the code I had:

[HTML]<a href="Logon.aspx?LOGOUT=LOGOUT">Log out</a>[/HTML]

..Since I was replying i decided to take another look real quick..I think I found the problem. Im sending that logout parameter..so on the postback when your there it logs out before going to the next page....is there a way to clear that on postback? Or should I look for a different way to handle the log out?
Sep 8 '08 #5
ShadowLocke
115 100+
The redirect is client side. The runat tag i thought would have been it. But this is the code I had:

[HTML]<a href="Logon.aspx?LOGOUT=LOGOUT">Log out</a>[/HTML]

..Since I was replying i decided to take another look real quick..I think I found the problem. Im sending that logout parameter..so on the postback when your there it logs out before going to the next page....is there a way to clear that on postback? Or should I look for a different way to handle the log out?
First all, thank you all for your replys. I found my problem..when I use the logout/timeout paramater I just added a check for IsPostBack. (in an inherited page I always forget to look into those things..assuming they did it right before i got here)
Sep 8 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Jim H | last post by:
We ahve a .NET web page that we dynamically create a bunch of DataGrids and add them to a place holder. When the user hits submit we need to go through all of the DataGrids to get some data. We...
3
by: Ravi | last post by:
Hi, I have a simple .aspx page where user enters data (e.g Name address, etc). At the end, he/she clicks Save button which Posts to the same page and in the Save button's click event I am saving...
1
by: Lolam | last post by:
Here is my problem, I am using 3 user controls in a page(Test.aspx) which are 1.Header UC 2.Body UC 3.Footer UC HeaderUC has a DropDownList control named "ddlList". On SelectIndexChanged...
2
by: Don | last post by:
I am trying to write my first ASP.net page and am having a little trouble, please help. I have a Page_Load sub that looks like this Private Sub Page_Load(ByVal sender As System.Object, ByVal e As...
3
by: erdem | last post by:
hi, i have a problem with asp.net when i was debugging i put breakpoint to pageload event and then i discovered that page is loaded once (explorer shows full page correctly but continues...
3
by: Brian Henry | last post by:
I have two list boxes on my form... lstCanSend and lstRecipients... well then there are two buttons add and remove between them (your basic select and pick listing) which uses java script to move...
3
by: Jim | last post by:
I have a drop-down list that posts back to the server, but on post back the page scrolls all the way to the top and I would like to have it go to a certain anchor. Does anyone know how to...
3
by: Ahmad Jalil Qarshi | last post by:
Hi, I am developing a website in ASP.NET. I want to have a client side code to confirm the deletion of some information from backend database. I want to use a Message Box have two buttons "Yes"...
12
by: Michael Lang | last post by:
I'm adding checkbox controls to a panel in a post back, I then have a second post back in which I attempt to process the checkbox controls however they seem to have disappeared off the panel. The...
8
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I the page knows there was a cross post back. but i can not find the control. (asp.net 3.5) calling page has a master calling control: <asp:Button ID="btnSendAlert" runat="server" Text="Go"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.