473,395 Members | 1,891 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,395 software developers and data experts.

No event trigger after casting session variable in OnPreInit

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??

Sep 14 '08 #1
1 1805
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"
Sep 14 '08 #2

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

Similar topics

6
by: Li Weng | last post by:
Hi, I have a button (btnSearch) and its Click event sub btnSearch_Click. Clicking the button will trigger the event. But how do I trigger this event in code? I tried RaiseEvent btnSearch.Click...
1
by: Rajesh Abraham | last post by:
I am new to Asp world and I have a doubt as follows. I have a class called objTranslator, which I declare and initiate global.asax as follows. Session_Start csTranslator.objTranslator...
6
by: Carlo Marchesoni | last post by:
I have an ASP.NET/C# solution, where I can perfectly cast something I stored in the session object to a class of mine (BackEnd), as this: ->be = (BackEnd)Session;<- But if I try to do the same:...
6
by: Beffmans | last post by:
Hi I want to hook the "back" event or "forward" event from a browser page. How can I trigger these events to my asp.net page? ch Beffmans *** Sent via Developersdex...
2
by: alain.hogue | last post by:
I known that by using the "Profile_MigrateAnonymous" event I can migrate my anonymous users profile to their authenticated account profile, but I would like to carry over some of the properties of...
8
by: Roger | last post by:
When I call the session.abandon() method, it calls the session_end event. When a user closes the browser or clicks the log off button, I can dispose of objects and abandon the session cleaning....
3
by: Morgan Cheng | last post by:
"Server.Transfer(Request.FilePath);" make server re-evaluate current page. In debugger, I found that though the page's OnPreInit is called, delegates attached in HttpModule is not executed. Why...
3
by: Mark Rae [MVP] | last post by:
"Lloyd Sheen" <a@b.cwrote in message news:uL5TPXPvIHA.1688@TK2MSFTNGP06.phx.gbl... Surely that will throw an exception because you're trying to populate a DataSet variable with an object...
2
by: =?Utf-8?B?R2Vvc3Ns?= | last post by:
Dear All, I try to change a master page in the OnPreInit in a asp.net page. (Session variable is guaranteed to have been assigned) protected override void OnPreInit(EventArgs e){ if...
4
by: AndreH | last post by:
Good day, I have the a bit of an issue with retrieving an object from php's session. I set a session variable "user" from the class User as follows: $user = new User(); // ... do some stuff...
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.