Post to another page from several submit buttons

Discussion in 'ASP .Net' started by Kees de Winter, Dec 11, 2006.

  1. 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
    Kees de Winter, Dec 11, 2006
    #1
    1. Advertising

  2. 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
    Lisa Ashley Rafter, Dec 11, 2006
    #2
    1. Advertising

  3. 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$...
    > 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, Dec 11, 2006
    #3
  4. Kees de Winter

    Damien Guest

    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
    Damien, Dec 11, 2006
    #4
  5. 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" <> wrote in message
    news:...
    > 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
    >
    Eliyahu Goldin, Dec 11, 2006
    #5
  6. Kees de Winter

    bruce barker Guest

    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.
    bruce barker, Dec 11, 2006
    #6
  7. Kees de Winter

    Damien Guest

    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
    Damien, Dec 12, 2006
    #7
  8. 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" <> wrote in message
    news:...
    > 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
    >
    Eliyahu Goldin, Dec 12, 2006
    #8
  9. 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$...
    > 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
    >
    >
    >
    Edwin Knoppert, Dec 12, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    1
    Views:
    1,689
  2. Ghafran Abbas
    Replies:
    0
    Views:
    4,207
    Ghafran Abbas
    Oct 12, 2004
  3. Replies:
    4
    Views:
    902
  4. Replies:
    6
    Views:
    206
  5. Otto Wyss

    Several submit buttons in a form

    Otto Wyss, Feb 13, 2007, in forum: Javascript
    Replies:
    2
    Views:
    78
    Randy Webb
    Feb 13, 2007
Loading...

Share This Page