sensible way to pass around values

Discussion in 'ASP .Net' started by David C, Aug 6, 2007.

  1. David C

    David C Guest

    With .NET 1.x, this is what I did. On the destination page

    public class ToWebForm : System.Web.UI.Page
    {
    public const string PARAMETER = "PARAM";
    protected void Page_Load(object sender, System.EventArgs e)
    {
    if (!IsPostBack)
    {
    string paramFromAnotherPage = Context.Items[PARAMETER].ToString();
    Response.Write(paramFromAnotherPage);
    }
    }
    }

    And on the source page
    Context.Items.Add(ToWebForm.PARAMETER, "value");
    Server.Transfer("ToWebForm.aspx");

    Basically I am creating an interface (not in a .net sense) on the
    destination page so that the source page can simply use the string
    constant as the name of the parameter.

    ..NET 2.0 does not seem to be happy with this. The funny thing is,
    sometimes it works, and sometimes it does not even compile, which I
    find very frustrating.

    Is there any reason why this won't work well with partial classes?

    And what is the sensible way to pass values from page to page without
    having to copy and past the parameter names all over the web project?
     
    David C, Aug 6, 2007
    #1
    1. Advertising

  2. ..NET 2.0 is "last page aware". Try this:
    http://msdn.microsoft.com/msdnmag/issues/05/10/ExtremeASPNET/

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    http://gregorybeamer.spaces.live.com
    Co-author: Microsoft Expression Web Bible (upcoming)

    ************************************************
    Think outside the box!
    ************************************************
    "David C" <> wrote in message
    news:...
    > With .NET 1.x, this is what I did. On the destination page
    >
    > public class ToWebForm : System.Web.UI.Page
    > {
    > public const string PARAMETER = "PARAM";
    > protected void Page_Load(object sender, System.EventArgs e)
    > {
    > if (!IsPostBack)
    > {
    > string paramFromAnotherPage = Context.Items[PARAMETER].ToString();
    > Response.Write(paramFromAnotherPage);
    > }
    > }
    > }
    >
    > And on the source page
    > Context.Items.Add(ToWebForm.PARAMETER, "value");
    > Server.Transfer("ToWebForm.aspx");
    >
    > Basically I am creating an interface (not in a .net sense) on the
    > destination page so that the source page can simply use the string
    > constant as the name of the parameter.
    >
    > .NET 2.0 does not seem to be happy with this. The funny thing is,
    > sometimes it works, and sometimes it does not even compile, which I
    > find very frustrating.
    >
    > Is there any reason why this won't work well with partial classes?
    >
    > And what is the sensible way to pass values from page to page without
    > having to copy and past the parameter names all over the web project?
    >
     
    Cowboy \(Gregory A. Beamer\), Aug 7, 2007
    #2
    1. Advertising

  3. David C

    David C Guest

    David C, Aug 7, 2007
    #3
  4. David C

    Ross Culver Guest

    Is there anyway to enable this for a gridview? Perhaps a user control or a
    hidden button?

    Ross


    "Cowboy (Gregory A. Beamer)" <> wrote in
    message news:%...
    > .NET 2.0 is "last page aware". Try this:
    > http://msdn.microsoft.com/msdnmag/issues/05/10/ExtremeASPNET/
    >
    > --
    > Gregory A. Beamer
    > MVP; MCP: +I, SE, SD, DBA
    > http://gregorybeamer.spaces.live.com
    > Co-author: Microsoft Expression Web Bible (upcoming)
    >
    > ************************************************
    > Think outside the box!
    > ************************************************
    > "David C" <> wrote in message
    > news:...
    >> With .NET 1.x, this is what I did. On the destination page
    >>
    >> public class ToWebForm : System.Web.UI.Page
    >> {
    >> public const string PARAMETER = "PARAM";
    >> protected void Page_Load(object sender, System.EventArgs e)
    >> {
    >> if (!IsPostBack)
    >> {
    >> string paramFromAnotherPage = Context.Items[PARAMETER].ToString();
    >> Response.Write(paramFromAnotherPage);
    >> }
    >> }
    >> }
    >>
    >> And on the source page
    >> Context.Items.Add(ToWebForm.PARAMETER, "value");
    >> Server.Transfer("ToWebForm.aspx");
    >>
    >> Basically I am creating an interface (not in a .net sense) on the
    >> destination page so that the source page can simply use the string
    >> constant as the name of the parameter.
    >>
    >> .NET 2.0 does not seem to be happy with this. The funny thing is,
    >> sometimes it works, and sometimes it does not even compile, which I
    >> find very frustrating.
    >>
    >> Is there any reason why this won't work well with partial classes?
    >>
    >> And what is the sensible way to pass values from page to page without
    >> having to copy and past the parameter names all over the web project?
    >>

    >
    >
     
    Ross Culver, Aug 7, 2007
    #4
    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. Hazz
    Replies:
    5
    Views:
    486
  2. gavnosis
    Replies:
    0
    Views:
    544
    gavnosis
    Aug 2, 2003
  3. Twisted
    Replies:
    552
    Views:
    6,891
    Twisted
    Dec 8, 2006
  4. Replies:
    5
    Views:
    288
    Jerry Coffin
    Nov 19, 2008
  5. Adrienne Boswell
    Replies:
    2
    Views:
    535
    Doug Miller
    Nov 8, 2009
Loading...

Share This Page