Connecting Tech Pros Worldwide Forums | Help | Site Map

Post to another page from several submit buttons

Kees de Winter
Guest
 
Posts: n/a
#1: Dec 11 '06
Hi,

On a form I have several submit-buttons, each of which should post its own
set of variables (e.g. price and name of a product) to another page, e.g. an
orderpage. There can only be one form, so what can I do now? I know I can do
it using a Javascript function that sets the variables in the form, but
isn't there any way without Javascript? Or can one rely on the user having
Javascript.

Using asp.net 2.0 VB.Net.
Thanks very much for any help.
--
Regards,
Kees de Winter




Lisa Ashley Rafter
Guest
 
Posts: n/a
#2: Dec 11 '06

re: Post to another page from several submit buttons


Hi Kees,
One way to do it is to make them all aspbuttons.
Put this on the form:
<asp:button id=myButton runat="server" Font-Size="8pt" Height="20px"
Width="64px" CausesValidation="False" Text="Copy"></asp:button>
Put this in your codebehind:
Private Sub myButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles myButton.Click
......
build your new URL here
myURL = "mypage.aspx" & ....
.....
response.redirect (myURL , true)
End Sub

Handle the click on the codebehind page, then build your URL you'll to
post with there.
There are other way's to do it......but this is one easy way.
Response.Redirect() sometimes isn't the best way though.
Hope that helps,
Lisa


Kees de Winter wrote:
Quote:
Hi,
>
On a form I have several submit-buttons, each of which should post its own
set of variables (e.g. price and name of a product) to another page, e.g. an
orderpage. There can only be one form, so what can I do now? I know I can do
it using a Javascript function that sets the variables in the form, but
isn't there any way without Javascript? Or can one rely on the user having
Javascript.
>
Using asp.net 2.0 VB.Net.
Thanks very much for any help.
--
Regards,
Kees de Winter
Eliyahu Goldin
Guest
 
Posts: n/a
#3: Dec 11 '06

re: Post to another page from several submit buttons


First of all, you can absolutely rely on user having javascript. Otherwise
your program won't be usable anyway. Nothing useful is possible in asp.net
without javascript.

Secondly, you can use the PreviousPage property on the second page to access
the property of the first page directly. This may save you from javascript.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


"Kees de Winter" <nospamwrote in message
news:457d5c71$0$13604$ba620dc5@text.nova.planet.nl ...
Quote:
Hi,
>
On a form I have several submit-buttons, each of which should post its own
set of variables (e.g. price and name of a product) to another page, e.g.
an
orderpage. There can only be one form, so what can I do now? I know I can
do
it using a Javascript function that sets the variables in the form, but
isn't there any way without Javascript? Or can one rely on the user having
Javascript.
>
Using asp.net 2.0 VB.Net.
Thanks very much for any help.
--
Regards,
Kees de Winter
>
>
>

Damien
Guest
 
Posts: n/a
#4: Dec 11 '06

re: Post to another page from several submit buttons


Eliyahu Goldin wrote:
Quote:
First of all, you can absolutely rely on user having javascript. Otherwise
your program won't be usable anyway. Nothing useful is possible in asp.net
without javascript.
>
I beg to differ. Plenty of useful applications have and will be written
in asp.net without using any javascript whatsoever. In our place, we
use javascript, but only to enhance the experience, not for core
functionality.

There was a whole thread discussing this back in September, started by
Mark Rae and titled "Javascript or not javascript". As an update from
my comments back then, now that we've been running our newest site for
3 months now, we're finding the javascript disabled crowd is currently
accounting for 27% of our traffic.

Damien

Eliyahu Goldin
Guest
 
Posts: n/a
#5: Dec 11 '06

re: Post to another page from several submit buttons


Damien,

In what sense do you call an application with bad user experience useful?

I still remember the time when developers where forced to program for MS-DOS
since not everyone had/wanted Windows. And in MS-DOS one could always
achieve the same functionality.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


"Damien" <Damien_The_Unbeliever@hotmail.comwrote in message
news:1165851097.325183.172800@80g2000cwy.googlegro ups.com...
Quote:
Eliyahu Goldin wrote:
Quote:
>First of all, you can absolutely rely on user having javascript.
>Otherwise
>your program won't be usable anyway. Nothing useful is possible in
>asp.net
>without javascript.
>>
>
I beg to differ. Plenty of useful applications have and will be written
in asp.net without using any javascript whatsoever. In our place, we
use javascript, but only to enhance the experience, not for core
functionality.
>
There was a whole thread discussing this back in September, started by
Mark Rae and titled "Javascript or not javascript". As an update from
my comments back then, now that we've been running our newest site for
3 months now, we're finding the javascript disabled crowd is currently
accounting for 27% of our traffic.
>
Damien
>

bruce barker
Guest
 
Posts: n/a
#6: Dec 11 '06

re: Post to another page from several submit buttons


there is no supported way in asp.net. their solution also uses
javascript. you can fall back to standard html which does support
multiple forms and postback urls.

-- bruce (sqlwork.com)

Kees de Winter wrote:
Quote:
Hi,
>
On a form I have several submit-buttons, each of which should post its own
set of variables (e.g. price and name of a product) to another page, e.g. an
orderpage. There can only be one form, so what can I do now? I know I can do
it using a Javascript function that sets the variables in the form, but
isn't there any way without Javascript? Or can one rely on the user having
Javascript.
>
Using asp.net 2.0 VB.Net.
Thanks very much for any help.
Damien
Guest
 
Posts: n/a
#7: Dec 12 '06

re: Post to another page from several submit buttons


Eliyahu Goldin wrote:
Quote:
Damien,
>
In what sense do you call an application with bad user experience useful?
>
I still remember the time when developers where forced to program for MS-DOS
since not everyone had/wanted Windows. And in MS-DOS one could always
achieve the same functionality.
>
--
Well, lets see.

For a long running process, if the user has javascript, they get a
stable page which uses ajax to check for progress and updates the page
apropriately. No javascript, they get a page that does a refresh every
five seconds - it looks jerky, but it works.

For a text box where the user has to provide the name of a company - we
have a drop-down list which pulls in possible names (based on what the
user has typed) from a list of ~200 most likely names to be typing. If
they don't have javascript, they don't get the list, but they can still
type in the company names (and anyone is allowed to enter a name not on
the list anyway)

For validation - if the client has javascript, they get client side
validation which saves round trips to the server if they've got errors
on the page. No javascript, they have to wait until they submit the
form to get the same kind of feedback.

So, if the user has *chosen* to disable javascript (and you'd hope
they'd be aware that doing so limits their user experience
possibilities), we still allow them to use our system.

Now, how do the penalties for developing like this work out? Well, you
have to have server side validation anyway, to protect yourself from
malicious people. The text box with the "predictive" text just renders
as a text box anyway - no development effort whatsoever for the
non-javascript approach. And the progress page? There are about twelve
additional lines of code to support the non-ajax functionality.

Damien

Eliyahu Goldin
Guest
 
Posts: n/a
#8: Dec 12 '06

re: Post to another page from several submit buttons


This is nice of you to cater for disable javascripting, but I doubt the
benefits of that override the limitations and the development penalties that
are too many to start counting.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


"Damien" <Damien_The_Unbeliever@hotmail.comwrote in message
news:1165911718.172851.223790@79g2000cws.googlegro ups.com...
Quote:
Eliyahu Goldin wrote:
>
Quote:
>Damien,
>>
>In what sense do you call an application with bad user experience useful?
>>
>I still remember the time when developers where forced to program for
>MS-DOS
>since not everyone had/wanted Windows. And in MS-DOS one could always
>achieve the same functionality.
>>
>--
Well, lets see.
>
For a long running process, if the user has javascript, they get a
stable page which uses ajax to check for progress and updates the page
apropriately. No javascript, they get a page that does a refresh every
five seconds - it looks jerky, but it works.
>
For a text box where the user has to provide the name of a company - we
have a drop-down list which pulls in possible names (based on what the
user has typed) from a list of ~200 most likely names to be typing. If
they don't have javascript, they don't get the list, but they can still
type in the company names (and anyone is allowed to enter a name not on
the list anyway)
>
For validation - if the client has javascript, they get client side
validation which saves round trips to the server if they've got errors
on the page. No javascript, they have to wait until they submit the
form to get the same kind of feedback.
>
So, if the user has *chosen* to disable javascript (and you'd hope
they'd be aware that doing so limits their user experience
possibilities), we still allow them to use our system.
>
Now, how do the penalties for developing like this work out? Well, you
have to have server side validation anyway, to protect yourself from
malicious people. The text box with the "predictive" text just renders
as a text box anyway - no development effort whatsoever for the
non-javascript approach. And the progress page? There are about twelve
additional lines of code to support the non-ajax functionality.
>
Damien
>

Edwin Knoppert
Guest
 
Posts: n/a
#9: Dec 12 '06

re: Post to another page from several submit buttons


You can fool asp.net by clearing out a view important objects using js like
viewstate and a few others.

Some partial code i grabbed from my site:

<script language="javascript">
function download()
{
var x = document.forms[0];
var sOldAction = x.action;
var sOldTarget = x.target;
var oVS = document.getElementById('__VIEWSTATE');
var sOldViewstate = oVS.value;
oVS.value = "";
x.action = "http://yoururlhere.aspx";
x.target = "_blank";
document.forms[0].submit();
x.target = sOldTarget;
x.action = sOldAction;
oVS.value = sOldViewstate;
}
</script>




"Kees de Winter" <nospamschreef in bericht
news:457d5c71$0$13604$ba620dc5@text.nova.planet.nl ...
Quote:
Hi,
>
On a form I have several submit-buttons, each of which should post its own
set of variables (e.g. price and name of a product) to another page, e.g.
an
orderpage. There can only be one form, so what can I do now? I know I can
do
it using a Javascript function that sets the variables in the form, but
isn't there any way without Javascript? Or can one rely on the user having
Javascript.
>
Using asp.net 2.0 VB.Net.
Thanks very much for any help.
--
Regards,
Kees de Winter
>
>
>

Closed Thread