Can I use "Session" inside a user control ?

Discussion in 'ASP .Net' started by craigkenisston@hotmail.com, Jun 12, 2005.

  1. Guest

    I'm creating a paging control in which I want to use a session saved
    dataview :

    public class PagingControl : System.Web.UI.UserControl
    ....
    ....

    public void whatever
    DataView dw;
    if (Session["Results"] != null)
    {
    dw = (DataView)Session["Results"];
    }
    else
    {
    return;
    }


    At the point of the "if" statement I get a null object reference error.
    So, may be I'm trying to do something not allowed ...
    Any idea ?
     
    , Jun 12, 2005
    #1
    1. Advertising

  2. Brock Allen Guest

    Perhaps you're doing this too early in the control's lifetime, like in the
    constructor?

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > I'm creating a paging control in which I want to use a session saved
    > dataview :
    >
    > public class PagingControl : System.Web.UI.UserControl
    > ...
    > ...
    > public void whatever
    > DataView dw;
    > if (Session["Results"] != null)
    > {
    > dw = (DataView)Session["Results"];
    > }
    > else
    > {
    > return;
    > }
    > At the point of the "if" statement I get a null object reference
    > error.
    > So, may be I'm trying to do something not allowed ...
    > Any idea ?
     
    Brock Allen, Jun 12, 2005
    #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. vatech1993
    Replies:
    4
    Views:
    5,723
    =?Utf-8?B?U8Opcmdpbw==?=
    Dec 11, 2004
  2. Leeor Chernov
    Replies:
    2
    Views:
    808
    Leeor Chernov
    Oct 16, 2005
  3. David Dorward
    Replies:
    1
    Views:
    2,172
    Isofarro
    Jun 28, 2003
  4. Roman
    Replies:
    2
    Views:
    281
    Roman
    Jan 4, 2005
  5. Kiran More
    Replies:
    2
    Views:
    341
    Kiran More
    Nov 14, 2006
Loading...

Share This Page