Should I use Viewstate?

Discussion in 'ASP .Net' started by Froefel, Jul 20, 2007.

  1. Froefel

    Froefel Guest

    One of my web pages is a page that allows the user to create or modify
    a project definition. It displays a feedback message when you've
    performed certain actions that causes the page to post back to itself
    (similar to Gmail's feedback messages). For instance, when you select
    several items from a gridview (using a checkbox field) and click a
    "Delete selected projects" link, I would display a message "5 projects
    were deleted." Wrapped in some Ajax, this is performing very smoothly.

    This same page can be used in 2 modes: "new" mode and "edit" mode.
    When creating a new project, the url is "CreateEditProject.aspx";
    when in edit mode the url is "CreateEditProject.aspx?
    mode=edit&pid=25", where pid is the ID of the project to be edited. On
    Page_Load I evaluate the QueryString and either do nothing or load an
    existing project and change some things on the page, such as changing
    the title from "Create New Project" to "Edit Project".

    When you load an existing project and click a "Save this project"
    link, the lnkSaveProject_Click() function is called, which saves the
    project, sets the feedback messages and displays the same page. The
    feedback message is displayed properly. Great!

    Now here's where the feedback message doesn't work anymore: when you
    start off with a new project and click the "Save this project" link,
    the lnkSaveProject_Click() function is called, which saves the new
    project, sets the feedback messages and then does a
    Response.Redirect("\CreateEditProject.aspx?mode=edit&pid=25") to
    render the same page in edit mode for the newly created project (with
    ID=25).
    The page renders fine, however the feedback message is not displayed.

    I have a feeling that this has something to do with the viewstate,
    where setting a property on a page that's auto-posted back to itself
    is stored in the viewstate and sent along to the client for rendering.
    If a Response.Redirect(url) is performed, then the viewstate of the
    url page is initially empty. The property change that happened by
    setting the feedback message was discarded when calling the
    Response.Redirect. Am I thinking correctly about this?

    So my question is, how can I display the feedback message when going
    from the "new" mode to the "edit" mode?

    Any help is greatly appreciated.
     
    Froefel, Jul 20, 2007
    #1
    1. Advertising

  2. "Froefel" <> wrote in message
    news:...

    > Any help is greatly appreciated.


    Please don't post the same message twice...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Jul 20, 2007
    #2
    1. Advertising

  3. Froefel

    Froefel Guest

    Actually i posted this message at least 5 times because for some
    reason, over the past 2 days none of my messages made it to the Group.
    Meanwhile i have confirmation that I'm not the only one, and as of
    last night, several of my messages finally made it to the group. I
    hope this was just a temporary hickup. Sorry for the inconvenience of
    duplicate messages.

    -- Hans


    On Jul 20, 8:36 am, "Mark Rae [MVP]" <> wrote:
    > "Froefel" <> wrote in message
    >
    > news:...
    >
    > > Any help is greatly appreciated.

    >
    > Please don't post the same message twice...
    >
    > --
    > Mark Rae
    > ASP.NET MVPhttp://www.markrae.net
     
    Froefel, Jul 20, 2007
    #3
    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. Lacrima
    Replies:
    43
    Views:
    813
    Mark Lawrence
    Aug 2, 2010
  2. steveh44
    Replies:
    12
    Views:
    761
    Daniele Futtorovic
    May 6, 2011
  3. ~~~ .NET Ed ~~~

    How should control images should be handled?

    ~~~ .NET Ed ~~~, Oct 31, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    243
    John Saunders
    Nov 3, 2004
  4. Josef 'Jupp' SCHUGT

    What the FAQs should and should not contain

    Josef 'Jupp' SCHUGT, Aug 19, 2005, in forum: Ruby
    Replies:
    0
    Views:
    197
    Josef 'Jupp' SCHUGT
    Aug 19, 2005
  5. botp
    Replies:
    6
    Views:
    220
    Joel VanderWerf
    Oct 5, 2010
Loading...

Share This Page