Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Post to another page from several submit buttons

Reply
Thread Tools

Post to another page from several submit buttons

 
 
Kees de Winter
Guest
Posts: n/a
 
      12-11-2006
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



 
Reply With Quote
 
 
 
 
Lisa Ashley Rafter
Guest
Posts: n/a
 
      12-11-2006
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:
> 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


 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      12-11-2006
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" <nospam> wrote in message
news:457d5c71$0$13604$(E-Mail Removed) ...
> 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
>
>
>



 
Reply With Quote
 
Damien
Guest
Posts: n/a
 
      12-11-2006
Eliyahu Goldin wrote:
> 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

 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      12-11-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Eliyahu Goldin wrote:
>> 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
>



 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      12-11-2006
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:
> 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.

 
Reply With Quote
 
Damien
Guest
Posts: n/a
 
      12-12-2006
Eliyahu Goldin wrote:

> 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

 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      12-12-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Eliyahu Goldin wrote:
>
>> 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
>



 
Reply With Quote
 
Edwin Knoppert
Guest
Posts: n/a
 
      12-12-2006
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" <nospam> schreef in bericht
news:457d5c71$0$13604$(E-Mail Removed) ...
> 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
>
>
>



 
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
Several submit buttons in a form Otto Wyss Javascript 2 02-13-2007 09:16 PM
shop cart list page with several remove buttons, no javascript wolfing1@gmail.com ASP General 6 06-19-2006 03:19 PM
Forms with multiple submit buttons vs 'form' objects with single 'submit' methods neil.fitzgerald@ic.ac.uk Python 4 04-14-2006 04:58 PM
Preventing Multiple submit (Disabling Submit Button Post Click) Solution Mark ASP .Net 1 12-13-2004 08:03 PM
Disable Submit Button on Post back and On Submit in ASP.net Ghafran Abbas ASP .Net 0 10-12-2004 06:11 PM



Advertisments