Search:
Namespaces
Discussions
.NET v1.1
Feedback
Not Answered: Querystring modification
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngfreeforall' list
.
Jason Peterson
Just wondering if anyone has ever had to do this...... redirecting works
fine, just seems kind of expensive.
-----Original Message-----
From: Jason Peterson
Sent: Friday, 09 August, 2002 11:10 AM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: Querystring modification
After reading this thread and a little playing around, I'm curious if
there is a way to remove an item from the QueryString after you're done
using it. The Request.QueryString collection is read-only. I'd assume
that, if this were even possible, it'd have to be done during the
page_load or maybe page_init, before the page is rendered to the
browser.
The only alternative I can think of is to redirect to the same page you
are at (and taking out what you don't want when defining the
destination).
Thanks,
Jason
-----Original Message-----
From: Feduke Cntr Charles R [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, 07 August, 2002 2:32 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: When submitting a form, whatever is in
the URL that called that page is saved and resent ??
Enrique,
How about:
if (!Page.IsPostBack || Request.QueryString["action"] == "whatever")
{
// load data from database
}
This is what I use in all of my similiar situations.
- Chuck
-----Original Message-----
From: Enrique Avalle [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, August 07, 2002 2:22 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: When submitting a form, whatever is in
the URL that called that page is saved and resent ??
Yes I fixed it with IsPostBack ...
It is not elegant but due to the needs of this page, there is no other
way to tell it what action to perform than by querystring so I can't
trigger an event or whatever as a more elegan solution. Users need to
access this edit page thru a link sent to them via email .. so I dont
find any other way out other than to include the necessary info in the
url itself :)
Thanks
Enrique
----- Original Message -----
From: Feduke <mailto:
Click here to reveal e-mail address
> Cntr Charles R
To: aspngfreeforall <mailto:
Click here to reveal e-mail address
>
Sent: Wednesday, August 07, 2002 2:57 PM
Subject: [aspngfreeforall] RE: When submitting a form, whatever is in
the URL that called that page is saved and resent ??
Enrique,
This is the class
Page
.IsPostBack check. Basically what you're
doing is populating a form during the Page_Load, which is correct.
However you must keep in mind the Page_Load event fires *every* time the
page loads (that is, even when you post back data to the page). The way
around this is to test and see if this is a IsPostBack or not and
populate only in those cases when the page is not posted back to itself
(of course this does not work when the <form> attribute <method> is set
to "GET"):
// your Page_Load dec
if (!Page.IsPostBack)
{
// load all my field data from the database
}
Also to figure out which events fire in what order, add an attribute
to your <% @Page %> directive in your *.aspx called Trace and set it to
true (<% @Page Trace="true" %>).
HTH,
- Chuck
-----Original Message-----
From: Enrique Avalle [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, August 07, 2002 1:18 PM
To: aspngfreeforall
Subject: [aspngfreeforall] When submitting a form, whatever is in the
URL that called that page is saved and resent ??
Here is the plot:
I got a page that can be called specifying in the url to get a form with
certain data to edit... example:
http://www.example.com/catalog.aspx?action=edit
<
http://www.example.com/catalog.aspx?action=edit
&code=23856" target="_blank">
http://www.example.com/catalog.aspx?action=edit
&code=23856> &code=23856
So this page brings to the client's explorer a form containing data from
product 23856 in order to be EDITED (hence the action=edit)
SO... On PageLoad I check "action" and if it carries "edit", I turn
visible an asp:panel with the edit form and populate it.
At the bottom of the form there is an ASP:BUTTON with an
onclick="processedit"
In process edit I fetch the form (with several xxx.value and xxx.text)
and save the edited data...
WHAT IS WRONG WITH THIS PLOT ???
WELL:
IT SEEMS that when data is submited, asp.net executes FIRST OF ALL my
PageLoad which I suppose that internally reconfigures my asp:panel with
the edit form and the ORIGINAL DATA in the database and when my sub
processedit kicks in to get the EDITED values, it just grabs THE
ORIGINAL ONES.
This happens apparently because the <form runat="server"> ends up being
in my edit page with an action of "catalog.aspx?action=edit&code=23856"
So it seems that asp.net STORES the URL info and resubmits it with the
form, something I DONT WANT.
Of course, if I try the good old request.form with the form fields that
where submitted, I DO GRAB THE CORRECT, EDITED values... so it seems
that if I go back into the old way, I can fix it, but I just dont want
that.
These are my first steps on asp.net, needless to say :) Please suggest
any alternative course of action :)
Regards,
Enrique Avalle
Reply to this message...
Feduke Cntr Charles R
I don't think you can get around it without a redirect. Once the
browser has decided on an address with querystring information to request,
then that's it - it doesn't matter what the server tries to do, the address
information remains the same on the client end without sending back a
redirect header. Communication between client and server here is key and is
required. If a browser supported a "Hey, get this item out of your
querystring..." variable in the HTTP header, then this could be done without
the redirect.
- Chuck
-----Original Message-----
From: Jason Peterson [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, August 14, 2002 11:16 AM
To: aspngfreeforall
Subject: [aspngfreeforall] Not Answered: Querystring modification
Just wondering if anyone has ever had to do this...... redirecting works
fine, just seems kind of expensive.
-----Original Message-----
From: Jason Peterson
Sent: Friday, 09 August, 2002 11:10 AM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: Querystring modification
After reading this thread and a little playing around, I'm curious if there
is a way to remove an item from the QueryString after you're done using it.
The Request.QueryString collection is read-only. I'd assume that, if this
were even possible, it'd have to be done during the page_load or maybe
page_init, before the page is rendered to the browser.
The only alternative I can think of is to redirect to the same page you are
at (and taking out what you don't want when defining the destination).
Thanks,
Jason
-----Original Message-----
From: Feduke Cntr Charles R [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, 07 August, 2002 2:32 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: When submitting a form, whatever is in the
URL that called that page is saved and resent ??
Enrique,
How about:
if (!Page.IsPostBack || Request.QueryString["action"] == "whatever")
{
// load data from database
}
This is what I use in all of my similiar situations.
- Chuck
-----Original Message-----
From: Enrique Avalle [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, August 07, 2002 2:22 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: When submitting a form, whatever is in the
URL that called that page is saved and resent ??
Yes I fixed it with IsPostBack ...
It is not elegant but due to the needs of this page, there is no other way
to tell it what action to perform than by querystring so I can't trigger an
event or whatever as a more elegan solution. Users need to access this edit
page thru a link sent to them via email .. so I dont find any other way out
other than to include the necessary info in the url itself :)
Thanks
Enrique
----- Original Message -----
From: Feduke Cntr Charles R <mailto:
Click here to reveal e-mail address
>
To: aspngfreeforall <mailto:
Click here to reveal e-mail address
>
Sent: Wednesday, August 07, 2002 2:57 PM
Subject: [aspngfreeforall] RE: When submitting a form, whatever is in the
URL that called that page is saved and resent ??
Enrique,
This is the class
Page
.IsPostBack check. Basically what you're doing is
populating a form during the Page_Load, which is correct. However you must
keep in mind the Page_Load event fires *every* time the page loads (that is,
even when you post back data to the page). The way around this is to test
and see if this is a IsPostBack or not and populate only in those cases when
the page is not posted back to itself (of course this does not work when the
<form> attribute <method> is set to "GET"):
// your Page_Load dec
if (!Page.IsPostBack)
{
// load all my field data from the database
}
Also to figure out which events fire in what order, add an attribute to
your <% @Page %> directive in your *.aspx called Trace and set it to true
(<% @Page Trace="true" %>).
HTH,
- Chuck
-----Original Message-----
From: Enrique Avalle [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, August 07, 2002 1:18 PM
To: aspngfreeforall
Subject: [aspngfreeforall] When submitting a form, whatever is in the URL
that called that page is saved and resent ??
Here is the plot:
I got a page that can be called specifying in the url to get a form with
certain data to edit... example:
http://www.example.com/catalog.aspx?action=edit
<
http://www.example.com/catalog.aspx?action=edit
&code=23856" target="_blank">
http://www.example.com/catalog.aspx?action=edit
&code=23856> &code=23856
So this page brings to the client's explorer a form containing data from
product 23856 in order to be EDITED (hence the action=edit)
SO... On PageLoad I check "action" and if it carries "edit", I turn visible
an asp:panel with the edit form and populate it.
At the bottom of the form there is an ASP:BUTTON with an
onclick="processedit"
In process edit I fetch the form (with several xxx.value and xxx.text) and
save the edited data...
WHAT IS WRONG WITH THIS PLOT ???
WELL:
IT SEEMS that when data is submited, asp.net executes FIRST OF ALL my
PageLoad which I suppose that internally reconfigures my asp:panel with the
edit form and the ORIGINAL DATA in the database and when my sub processedit
kicks in to get the EDITED values, it just grabs THE ORIGINAL ONES.
This happens apparently because the <form runat="server"> ends up being in
my edit page with an action of "catalog.aspx?action=edit&code=23856"
So it seems that asp.net STORES the URL info and resubmits it with the form,
something I DONT WANT.
Of course, if I try the good old request.form with the form fields that
where submitted, I DO GRAB THE CORRECT, EDITED values... so it seems that if
I go back into the old way, I can fix it, but I just dont want that.
These are my first steps on asp.net, needless to say :) Please suggest any
alternative course of action :)
Regards,
Enrique Avalle
| ASP.net DOCS =
http://www.aspng.com/docs
| [aspngfreeforall] member
Click here to reveal e-mail address
= YOUR ID |
http://www.asplists.com/aspngfreeforall
JOIN/QUIT | news://ls.asplists.com = NEWSGROUP
Reply to this message...
System.Web.UI.Page
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com