W
wendylau81
We are currently using ASP.NET 2.0 to revamp one of our web
applications. Let me try to briefly explain how each page is laid
out...
Usually within the page, there are 3 components... The header, the
body, and the footer. The header and footer are user controls created
by one of our developers, and contain things that all the pages in our
web app should contain. This is done to avoid inconsistencies (so you
only change the header once instead of changing it 20 times - once for
each page).
The developer who created the header user control used Context.Items to
store some information. On my pages, I am trying to use PostbackUrl to
post form information from one page to another.
The problem I am having is this:
Both my pages call the header control. When I use PostbackUrl and
PreviousPage, I think the header control from the previous page gets
"copied" over to the page I am posting to. So in the second page, I get
something like a "dictionary keys have to be unique" exception. I think
this is because the Context.Items wasn't "cleared" from the
PreviousPage since it was "copied" over, so when the header user
control tries to add the same key to
Context.Items in the second page, I get an exception.
I temporarily solved this problem by using Request.Form[...] rather
than PreviousPage.FindControl(...). I'm not sure if this is the right
way to do it, or if it will cause any problems.
So my question is: Can PostbackUrl and Context.Items work together? I
guess I could put some try/catch statements in the header control, but
unfortunately I don't have access to that file.
Thanks for your help!
applications. Let me try to briefly explain how each page is laid
out...
Usually within the page, there are 3 components... The header, the
body, and the footer. The header and footer are user controls created
by one of our developers, and contain things that all the pages in our
web app should contain. This is done to avoid inconsistencies (so you
only change the header once instead of changing it 20 times - once for
each page).
The developer who created the header user control used Context.Items to
store some information. On my pages, I am trying to use PostbackUrl to
post form information from one page to another.
The problem I am having is this:
Both my pages call the header control. When I use PostbackUrl and
PreviousPage, I think the header control from the previous page gets
"copied" over to the page I am posting to. So in the second page, I get
something like a "dictionary keys have to be unique" exception. I think
this is because the Context.Items wasn't "cleared" from the
PreviousPage since it was "copied" over, so when the header user
control tries to add the same key to
Context.Items in the second page, I get an exception.
I temporarily solved this problem by using Request.Form[...] rather
than PreviousPage.FindControl(...). I'm not sure if this is the right
way to do it, or if it will cause any problems.
So my question is: Can PostbackUrl and Context.Items work together? I
guess I could put some try/catch statements in the header control, but
unfortunately I don't have access to that file.
Thanks for your help!