Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to stop control events from firing in Page_Load

Reply
Thread Tools

How to stop control events from firing in Page_Load

 
 
Ahmet Gunes
Guest
Posts: n/a
 
      06-19-2005
Hi all,

[I am sure it's a simple question to most of you ]

I check whether session is alive in Page_Load.
If session is not alive then I want to navigate to another page, most
probably the login page.
But when a control, a button for example, is clicked, after Page_Load the
button's click event is also fired.
Since session is abandoned at this moment, any object references raise
"object reference not set" exception.

Since my application contains frames I do not use Server.Transfer or
Response.Redirect. In stead, I use client side javascript code to navigate
to the login page in the "top" window.

What's the workaround of this situation?

thanks in advance,

AG



 
Reply With Quote
 
 
 
 
Norman Yuan
Guest
Posts: n/a
 
      06-19-2005
You cannot stop event firing, it is biult into the page processing. You can
choose not handling or handling correctly (in your case).

For example, your problem could be the user click a button after a long
pause so that the session has been timed out. You simply:

private Button1_Click(....)
{
if (Session["MyObject"]==null)
{
Response.Redirect("OtherPage.aspx");
return;
}

//Do regular buton-click handling
}

BTW, if you wnat to redirect user to a loggin page, why not using Form
authentication, which automatically handles loggin redirecting for you if
session is timed out.

"Ahmet Gunes" <> wrote in message
news:...
> Hi all,
>
> [I am sure it's a simple question to most of you ]
>
> I check whether session is alive in Page_Load.
> If session is not alive then I want to navigate to another page, most
> probably the login page.
> But when a control, a button for example, is clicked, after Page_Load the
> button's click event is also fired.
> Since session is abandoned at this moment, any object references raise
> "object reference not set" exception.
>
> Since my application contains frames I do not use Server.Transfer or
> Response.Redirect. In stead, I use client side javascript code to navigate
> to the login page in the "top" window.
>
> What's the workaround of this situation?
>
> thanks in advance,
>
> AG
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamically adding controls with events (but events are not firing) SevDer ASP .Net 2 11-13-2007 06:33 AM
How can I stop my Calendar control from firing the form validation events? mark4asp ASP .Net 3 03-08-2007 06:00 PM
Events fire and then stop firing Randy ASP .Net 0 12-06-2006 03:28 PM
Multiple Page_Load events firing gellis99@aol.com ASP .Net 3 01-30-2006 02:11 PM
Page_Load not firing in web user control ascx.vb C K ASP .Net 2 08-20-2003 09:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57