No event trigger after casting session variable in OnPreInit

Discussion in 'ASP General' started by Geossl, Sep 14, 2008.

  1. Geossl

    Geossl Guest

    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??
     
    Geossl, Sep 14, 2008
    #1
    1. Advertising

  2. 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"
     
    Bob Barrows [MVP], Sep 14, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ram
    Replies:
    0
    Views:
    584
  2. WT
    Replies:
    8
    Views:
    3,521
    Walter Wang [MSFT]
    Feb 14, 2007
  3. Geossl
    Replies:
    2
    Views:
    307
    Geossl
    Sep 16, 2008
  4. Anthony Papillion

    TkInter bind() event is not firing event trigger

    Anthony Papillion, Jun 23, 2010, in forum: Python
    Replies:
    3
    Views:
    1,693
    rantingrick
    Jun 23, 2010
  5. GJones

    Session Variable For A Sequel Trigger

    GJones, Nov 20, 2003, in forum: ASP General
    Replies:
    4
    Views:
    129
Loading...

Share This Page