Page Load/Click Event Timing Issue

I have a webform that alters it's content depending on whether or not the 
current user is logged in. It does this in the Page_Load event.

My master page has a logout button. If the user clicks this button, it fires 
the Page_Load event in my content page, the Page_Load event in my master 
page, and finally the Logout_Click event for my logout button.

This means that my code that alters the page (depending on whether or not 
the current user is logged in) fires before the code that logs the user out. 
This results in serving a page for a logged-in user when they are now logged 
out.

I'm not sure how best to handle this. My page has a lot of initialization 
code that I do not want to run twice. If it's a postback, I need to delay my 
initialization code somehow until after the Logout_Click event has executed 
on the master page.

I welcome any helpful suggestions.

Jonathan
 

0
Jonathan
5/15/2010 11:56:26 PM
dotnet.framework.aspnet 1425 articles. 0 followers. Follow

3 Replies
782 Views

Similar Articles

[PageSpeed] 7

On Sat, 15 May 2010 17:56:26 -0600, "Jonathan Wood"
<jwood@softcircuits.com> wrote:

>I have a webform that alters it's content depending on whether or not the 
>current user is logged in. It does this in the Page_Load event.
>
>My master page has a logout button. If the user clicks this button, it fires 
>the Page_Load event in my content page, the Page_Load event in my master 
>page, and finally the Logout_Click event for my logout button.
>
>This means that my code that alters the page (depending on whether or not 
>the current user is logged in) fires before the code that logs the user out. 
>This results in serving a page for a logged-in user when they are now logged 
>out.
>
>I'm not sure how best to handle this. My page has a lot of initialization 
>code that I do not want to run twice. If it's a postback, I need to delay my 
>initialization code somehow until after the Logout_Click event has executed 
>on the master page.
>
The Page type's IsPostback property is self-descriptive.

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // intialization code
            }
        }

regards
A.G.
0
Registered
5/16/2010 1:20:55 AM
"Registered User" <n4jvp@ix.netcom.com> wrote:

>>I'm not sure how best to handle this. My page has a lot of initialization
>>code that I do not want to run twice. If it's a postback, I need to delay 
>>my
>>initialization code somehow until after the Logout_Click event has 
>>executed
>>on the master page.
>>
> The Page type's IsPostback property is self-descriptive.

Yes it is. But it escapes me how that helps me delay my initialization code 
somehow until after the Logout_Click even has executed on the master page. 
Moreover, this issue comes up on several content pages. I was hoping for 
some sort of solution on the master page.

Jonathan
 

0
Jonathan
5/16/2010 2:55:01 PM
On Sun, 16 May 2010 08:55:01 -0600, "Jonathan Wood"
<jwood@softcircuits.com> wrote:

>"Registered User" <n4jvp@ix.netcom.com> wrote:
>
>>>I'm not sure how best to handle this. My page has a lot of initialization
>>>code that I do not want to run twice. If it's a postback, I need to delay 
>>>my
>>>initialization code somehow until after the Logout_Click event has 
>>>executed
>>>on the master page.
>>>
>> The Page type's IsPostback property is self-descriptive.
>
>Yes it is. But it escapes me how that helps me delay my initialization code 
>somehow until after the Logout_Click even has executed on the master page. 

How many times should a page instance be initialized? I think what you
want to do is load a new instance of the page from the Logout_Click
event handler.  This can be done with a Server.Transfer or
Response.Redirect call.

>Moreover, this issue comes up on several content pages. I was hoping for 
>some sort of solution on the master page.
>
It's not a bad idea to use the IsPostback member in any page's
Page_Load handler where there is initialization code.

regards
A.G.
0
Registered
5/16/2010 5:18:54 PM
Reply:

Similar Artilces:

Mirror pages
We working on a 55 page catalog that is using the ACCENT BOX layout that came with Publisher. Every page has a pageholder/header at the top that shows the name of the catalog, the page number and a little image. When we began this, we were adding single pages (not knowing about the master page concept). Now we have all the pages ready but we've noticed that the page numbers within the pageholder and image are all on the top right of every page. What we would prefer is that they be mirrored with the left pages (odd number) having these items on the left hand corner and the right ...

All pages display on each page
I am having a problem with 2002 version that displays every page in the publication as one. Essentially every page is overlayed on every other page which makes the whole thing look like a big mess. Any suggestions as to how to cure this ? You maybe experiencing video driver failure. Do this, slide the acceleration down on your adapter, control panel, display folder, settings tab, advanced button, troubleshoot tab, slide the acceleration down a couple of notches. If this solves your issue go to the manufacturer's web site of your graphics card and look around for an upgraded driver. D...

How to have more than one page on web site
I am trying to upload a newsletter to a website, but only the front page appears. How do I get all of the pages to appear? ...

Load Spreadsheet Tab
Is there a way to load an existing seperate spreadsheet into an individual worksheet in a seperate spreadsheet? "Danny McMillian" <anonymous@discussions.microsoft.com> wrote in message news:070001c3de98$8ec7f450$a401280a@phx.gbl... > Is there a way to load an existing seperate spreadsheet > into an individual worksheet in a seperate spreadsheet? You can open both workbooks together and then move (or copy) a worksheet from one to the other. To switch between two open workbooks, use the Window menu and click on the book name in the dropdown menu. To move (or copy) a wor...

IFD Sign In Page
This is a multi-part message in MIME format. ------=_NextPart_000_0019_01C8940A.D1DDFFB0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi All, Can we leverage credentails passed to "Sign In" page of MS CRM 4.0 in = IFD environment? I want to use it for making call to Discovery service = to fetch organization details. Thanks Rajeev ------=_NextPart_000_0019_01C8940A.D1DDFFB0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//...

creating an e-mail hyperlink from a web page
Can anyone tell me what format I need to use to format a hyperlink that customers can click the submit button and communicate via e-mail to me from our web page. -- Gina I presume you know how to insert a hyperlink, and that given your use of the words "submit button", that you are actually asking about how to get the forms feature to work. Reference: Publisher web publication forms 101 http://msmvps.com/blogs/dbartosik/archive/2006/01/07/80564.aspx And then you will probably want to read the article about HTTP uploading protocol, and the troubleshooting article here: http:...

Moving selection right one column at a time: Is there a shortcut?
After selecting some cells in a column how can I move the entire selection (not the content, just the selection) in the next column on the right? In the Excel for mac there is the ALT+TAB shortcut. Is there something similar for the pc version? Thanks None I'm aware of. Gord Dibben MS Excel MVP On Mon, 18 May 2009 16:09:02 -0700, RD <RD@discussions.microsoft.com> wrote: >After selecting some cells in a column how can I move the entire selection >(not the content, just the selection) in the next column on the right? In the >Excel for mac there is the ALT+TAB shortc...

Problem with SDK pages after changing SQL port number
We have encountered an issue where our SDK applications no longer can connect to CRM, however the CRM application itself works fine. This happened after we changed the port number for the SQL server - which was changed to solve a different issue. The error is: [Exception: ErrorMessage: SOAP Server Application Faulted <detail><error><code>80004005</code><description>Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.</description></error></detail> Source: System.Web.Services] It comes from th...

Loading a customized ribbon not associated with a form
I have an Access 2003 application that we are converting to Access 2007. I have (finally) figured out how to create customized ribbons to replace the customized menu's in the older version. And I have figured out how to associate specific ribbons with specific forms. Now I have to figure out a way to load another customized ribbon during Query Design, which doesn't appear to have an actual form. The code that loads the Query Design form in the Access 2003 version is: DoCmd.OpenQuery strQueryFullName, acViewDesign, acEdit DoCmd.RunCommand acCmdDesignView ...

loading web pages
what is the easiest way to load a web page in vc++? thanks Depends upon what you mean load. If you mean launching default browser, use ShellExecute. If you mean to load it in your MFC app, use CHTMLView. Other options are MSHTML, IWebBrowser2 etc. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com <anonymous@coolgroups.com> wrote in message news:08836cee5638a933f900557a8deb7d83@news.scbiz.com... | what is the easiest way to load a web page in vc++? | | thanks >-----Original Message----- >what is the easiest way to load a web page in vc++? > >thanks >. > microsoft ...

Suggestion: RMS New Customer Issue
RMS (any version) When the 'Find Customer' form first comes up, the cursor is in the right place and simply typing and hitting <ENTER> brings up a list. If you can find the customer in the list, you can simply select them by using the arrow keys (or mouse) and hit <ENTER> to set the customer for the new transaction. If the customer is not in the database and a new customer is required, RMS falls flat on its face. SUGGESTION: If a New customer is generated at POS, that customer should AT LEAST become the selected customer in the Find Customer form when you click O...

Page up and Page down
Is there any way the you can use Code to cause a form to do page up and page down. I have a Long form that some of the information that is at the bottom of the form is out of view and only use by certain people. How can I have a botton on click go page down to the bottom and another button that will return the form to the top of the form. I know that you can use the keys to accomplish this but for appearance value I would rather use a button on the form to accomplish this. any ideas? Sandrao, You can put a Page Break control on your form. Then, code on the Click event of your button...

add .NET unregister event capability from VS Tools
Because of the architecture of the .NET wrapper classes for GP resources it's critical to be able to unregister events. Othewise some nasty workarounds have to be enginneered to go around this limitation. Case in point: When using FormFactory to launch wrapper forms or own forms one will potentially register to a state field on the dex window exposed via the dex form. Each time the wrapper form is launched it registers a new event handler to the same event. When the form wrapper object gets disposed the memory will never be reclaimed by the gc because of the stray delegate to the e...

Where did the other pages go in my booklet?
Opened an 8 page booklet to update it and print. (Created in Publisher 2003) The only page that is there is the first page. 7 pages are gone. Opened a brochure to print and all that is there is the front side. The extra pages seemed to have disappeared during one of the Microsoft updates. Is there any way to retrieve or find these missing pages? Disappearing pages don't happen during updates. Are you using 2007? Is it a trial? Do you have the page tabs visible in the status bar? -- Mary Sauer http://msauer.mvps.org/ "PDX Sue" <PDX Sue@discussions.mic...

Printing Appts from multiple Calendars on one page- How
Hi Guys. I have a client that uses Exchange 2k3 and Outlook 2k3 for a Calendaring/appointment system for their offices. The person at the front desk makes most of the appointments directly into the user's Calendars via shared calendars. While she can see multiple calendars at once, she would like to be able to print out one page that contains the appointments of multiple calendars. ie; Appointments from multiple calendars time slotted down the page. She needs to be able to juggle interview rooms and other resources and she has to know who has appts at what times. Any ideas on this one?...

How to Make Page No dissapear if there is only one Page
Hi, Is there a way in MS Word 2003 and 2007 for making the page number display only if there is more than one pages. ie. the moment the pages become 2 the page number should appear and the moment the page number become 1 the page number should dissapear. Please help me out of this Regards, Akhil You could use a conditional field combination in the header/footer {IF {Numpages} > 1 {Page}} It will work in any version -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Wor...

I lost my page sorter at the bottom left hand side. How do I get.
I cannot find the page sorter and thus cannot go to different pages. How do I get the page sorter back? Thanks, Myra While in a state of ecstasy after repairing his laptop, Ed sees a message from Rice MS Newsletter Editor <RiceMSNewsletterEditor@discussions.microsoft.com>. On it is written: > I cannot find the page sorter and thus cannot go to different pages. > How do I get the page sorter back? Thanks, View > Status Bar is normally the first port of call -- Ed Bennett - MVP Microsoft Publisher http://www.mvps.org/the_nerd/ Before reading this message, view the disclaim...

Transfer 56 Pages of Data From Clipboard=?ISO-8859-1?B?iiA=?=To Clipboard?
You Mean there IS a Multi-Panel Clipboard in Office 2004?!? Oooppps! I Haven't seen it! Any Clues where it Might Be? You Guys are Great: Thanks for All the Help!! Sea Mac I'm Putting the Stock Phrases in the Scrapbook for Now but will chase down this Auto-Text thing. I hadn't seen it because I'm not using Office 2004 yet, so don't waste any time on my careless words. On 9/30/04 10:21 PM, "Sea Mac" wrote: > You Mean there IS a Multi-Panel Clipboard in Office 2004?!? Oooppps! I > Haven't seen it! Any Clues where it Might Be? You Guys are Gr...

Error on the script of this page
This is a multi-part message in MIME format. ------=_NextPart_000_0009_01C6FD1E.A3BEE240 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, Every time I open personal folders, I get a message saying: Error on the script of this page line 298 car 1 error: non registered class code 0 =20 URL: outlook today I close it, and then every thing works OK Thank you for your help if possible Louis MOUSSY ------=_NextPart_000_0009_01C6FD1E.A3BEE240 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-...

won't load
Outlook 2002 will not load. If I bring up the task manager Outlook.exe is consuming 97% of the CPU. If the process is ended then I can start Outlook in safe mode but if I shut it down then I have to go through the process of trying to start it again, end the process and then start in safe mode. I never get an error message. Any ideas? How big is the .pst file? Perhaps it has grown so large, it's exceeding the system's capacity. Have you tried emptying the deleted items folder? Have you tried to archive the old emails to reduce the size of the .pst file. If it's alrea...

How to "flip" pages in Reading Layout
At work, we use outlook professional, and documents are sent in "Reading Layout" format. Trouble is, I don't know how to flip the pages. Can you please help me? This is the message I get when I open a mult-page document in MS Word. Welcome to Reading Layout (Microsoft Office Word) This view has been designed to make it easier to read documents on your screen without needing to print them out. Reading Layout: • Lets you flip pages, like reading a book. • Uses large text with ClearType for easy reading. • Is an ideal place to review and comment on a document. • Shows only th...

How to format a range of numbers (single column) to time format in MS Excel
Guys, Can any one of you tell me how I can convert or format a range o numbers in a single column into a range of times (time format)? Is i possible? Example.. 0945 - 1000 is to be converted to 9:45 - 10:0 -- Message posted from http://www.ExcelForum.com Hi Sam, Here's some code to do it Dim cell As Range For Each cell In Selection cell.Value = TimeSerial(cell.Value \ 100, cell.Value Mod 100, 0) Next cell -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Sam96434 >"...

Displaying XML Stream on ASP.NET Page
I am writing an application which will get stream of XML Data from a CRM application. I am able to make HTTP request and retrieve the xml stream in XML Text Reader. I want to display this data on an ASP.NET page. I have done some research and found that there is XML Web Server control in ASP.NET. However, all the examples I have seen utilize a XML document and not an XML Stream or XMLTextReader object. Can XML Web Server control also read from XML Text Reader. Also, what other options can I use to display stream of XML Data on ASP.NET Page. Any help would be greatly appreciated. Ashish wrot...

Paging Limit
Hi all, I've a little Pronlem with the Paging Limit. In Version 1.2 You can set the Max or min Value in the <CRMWeb>\Tools\personalsettings\dialogs\personalsettings.aspx file. But how can a set this in the 3.0? My Problem is some of your useres select 250. But this value is to large. The should only have 50. I can set it in the UserSettings Database, but all useres can set it again to 250. So I must lock the Values over 50 for each user. So I hope somebody know how I can change this. Thanks, Andre ...

layout guides and page set up
Hi Everyone i have layout guides that i use to for templates, but when i turn the page from portrait to landscape the layout guides don't move with the paper the just resize themselves to fit along the landscape - what is the best way to have the layout guides move when the page is changed? Thanks Heaps Patchie There is no best way, the only way is to manually reposition the guides. The guides don't actually change position, you can test this by creating guides in the center horizontal and vertically. When you change the orientation the guides are still centered. -- Mary Sau...