WebControl, WSS, Session

Discussion in 'ASP .Net Web Controls' started by chris, Nov 22, 2007.

  1. chris

    chris Guest

    'm having some problems with a WebControl, Sharepoint and
    SessionState. and NullReferences.

    Somewhere, this method it throwing a NullReference Exception. It
    began when I added the session information.

    Options for null -
    base - not likely - worked before SS added.

    I think I handled the case of the empty session appropriately, if not
    overzealously. Is there something funky about WSS and SessionState? Or
    am I getting the SessionState from the wrong place?

    Class Declaration: public class WebQuizControl : WebControl

    The Method:
    protected override void CreateChildControls()
    {
    base.EnsureChildControls();
    if ( !isConfigured ) return;
    object temp = null;
    if (! HttpContext.Current.Session.IsNewSession)
    temp = HttpContext.Current.Session["questionSet"];

    // Does C# shortcut here? if temp == null is the castI
    executed?
    if ( temp == null || ( temp as ExamCreator ) == null )
    {
    questionSet = new ExamCreator( Association, course,
    module ); // parameters are valid
    HttpContext.Current.Session.Add( "questionSet",
    questionSet );
    }
    else // Probably not in here, as it crashes on initial
    load.
    {
    questionSet =
    HttpContext.Current.Session["questionSet"] as ExamCreator;
    }
    foreach ( Question q in questionSet.Questions )
    {
    this.Controls.Add( q );
    }

    // [snip] .. add submit, reset etc.
    }
     
    chris, Nov 22, 2007
    #1
    1. Advertisements

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. john
    Replies:
    0
    Views:
    410
  2. Guest
    Replies:
    2
    Views:
    920
  3. Luis Ramírez.

    Can a webcontrol (webcontrol.dll) have a configuration file?

    Luis Ramírez., Jul 5, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    418
    Luis Ramírez
    Jul 6, 2004
  4. Kasabaarde Sumta

    WebControl inside of WebControl and attaching events

    Kasabaarde Sumta, Dec 13, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    327
    Kasabaarde Sumta
    Dec 13, 2004
  5. Fabricio

    Custom webcontrol that references another webcontrol

    Fabricio, Sep 21, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    340
    Fabricio
    Sep 21, 2005
  6. Peter Morris [Air Software Ltd]

    WebControl with non-WebControl property

    Peter Morris [Air Software Ltd], Dec 7, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    239
    Peter Morris [Air Software Ltd]
    Dec 7, 2004
  7. Steven

    Adding a WebControl to a WebControl

    Steven, Oct 13, 2008, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    204
    Steven
    Oct 13, 2008
  8. Sven W.
    Replies:
    1
    Views:
    279
    Bob Barrows [MVP]
    Jan 20, 2008
Loading...