Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > No event trigger after casting session variable in OnPreInit

Reply
Thread Tools

No event trigger after casting session variable in OnPreInit

 
 
Geossl
Guest
Posts: n/a
 
      09-14-2008
Dear All,
I try to change a master page in the OnPreInit in a asp.net page.
protected override void OnPreInit(EventArgs e){
if ((bool)session["IsNew"]){
this.MasterPageFile = "~/NewMaster.master";
}
else{
this.MasterPageFile = "~/OrigianlMaster.master";
}
base.OnPreInit(e)
}

But after this, the page does not trigger any other event. I try to trace to
the problem , and when I remove the casting of the session variable,
if ((bool)session["IsNew"]){
to
if (session["IsNew"] == null)

then, everything works fine again.

Why casting a session variable will inhibit the triggering of other events
in the page??



 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      09-14-2008
Geossl wrote:
> Dear All,
> I try to change a master page in the OnPreInit in a asp.net page.


There was no way for you to know it (except maybe by browsing through some
of the previous questions in this newsgroup before posting yours - always a
recommended practice) , but this is a classic (COM-based) asp newsgroup.
ASP.Net bears very little resemblance to classic ASP so, while you may be
lucky enough to find a dotnet-knowledgeable person here who can answer your
question, you can eliminate the luck factor by posting your question to a
group where those dotnet-knowledgeable people hang out. I suggest
microsoft.public.dotnet.framework.aspnet or the forums at www.asp.net.


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
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
TkInter bind() event is not firing event trigger Anthony Papillion Python 3 06-23-2010 12:55 AM
No event trigger after casting session variable in OnPreInit Geossl ASP .Net 2 09-16-2008 01:18 AM
System Session Variable VS. Own-declared 'Session' Variable chowchho ASP .Net 7 03-28-2008 02:38 PM
Why OnPreInit unvailable on controls WT ASP .Net 8 02-14-2007 06:36 AM
Session Variable For A Sequel Trigger GJones ASP General 4 11-20-2003 10:03 PM



Advertisments