Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Querystring or ViewState question

Reply
Thread Tools

Querystring or ViewState question

 
 
Froefel
Guest
Posts: n/a
 
      07-19-2007
Hi group,

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=e dit&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.
-- Hans

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      07-19-2007
Correct. If you still need to redirect (you could also consider
server.transfer, which is more efficient) then consider putting the message
on the querystring and picking it up from there to redisplay.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com



"Froefel" wrote:

> Hi group,
>
> 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=e dit&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.
> -- Hans
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Querystring or ViewState question Froefel ASP .Net 0 07-19-2007 11:28 PM
Querystring or ViewState question Froefel ASP .Net 0 07-19-2007 12:20 PM
Querystring or ViewState question Froefel ASP .Net 1 07-19-2007 09:08 AM
How to get value of QueryString inside QueryString Mehdi ASP .Net 6 04-06-2006 03:41 PM
Passing QueryString URL as a paremeter in QueryString Adeel Ahmad ASP General 1 03-07-2006 02:05 PM



Advertisments