No event trigger after casting session variable in OnPreInit

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?R2Vvc3Ns?=

    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(Event Args e){
    if ((bool)session["IsNew"]){
    this.MasterPage File = "~/NewMaster.maste r";
    }
    else{
    this.MasterPage File = "~/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??



  • Bob Barrows [MVP]

    #2
    Re: No event trigger after casting session variable in OnPreInit

    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.publi c.dotnet.framew ork.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"


    Comment

    Working...