[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

update database before post data to another page

Posted on 2011-02-27
10
Medium Priority
?
885 Views
Last Modified: 2013-12-25
Hi,

below is my asp.net page. clicking button1 posts all hidden input data to a paypal page and redirect to the paypal page.

However, I need to update database before post these data to another page and redirect. It means in the button1_Click event I need to update database first and and then post data + redirect to paypal page

anyone can show me how to do it?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="posturl.aspx.cs" Inherits="testWeb.posturl" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="hidden" name="cmd" value="_xclick" />
        <input type="hidden" name="business" value="xxx@yahoo.com" />
        <input type="hidden" name="lc" value="AU" />
        <input type="hidden" name="item_name" value="Order Item 100000"/>
        <input type="hidden" name="amount" value="100.00" />
        <input type="hidden" name="currency_code" value="AUD" />
        <input type="hidden" name="button_subtype" value="services" />
        <input type="hidden" name="no_note" value="0" />

        <asp:Button ID="Button1" runat="server" Text="Button" 
            PostBackUrl="https://www.paypal.com/cgi-bin/webscr" onclick="Button1_Click" />
    </div>
    </form>
</body>
</html>

Open in new window

0
Comment
Question by:viola123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 6

Author Comment

by:viola123
ID: 34994272
let's make the question simpler:

I need to post the data from button1_Click() and redirect to paypal page

How to do this?
0
 
LVL 13

Expert Comment

by:Rahul Agarwal
ID: 34994355
Add Id and Runat="Server" to each input field, by doing this you can access these field on Code behind page by using input field id.value and on button click save these field to DB and then response.redirect to "https://www.paypal.com/cgi-bin/webscr"

For e.g:

<input type="hidden" id="Input1" runat="Server" name="cmd" value="_xclick" />

Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
         dim input as string=Input1.value
          insert into DB
         response.redirect("https://www.paypal.com/cgi-bin/webscr")
0
 
LVL 6

Author Comment

by:viola123
ID: 34994366
Hi, agarwalrahul:

I don't need save those hidden filelds data in database. I meant I need to update database for other reason. I just need to do SOMETHING in codebehind before post data

forget the database update. I need to post data to the paypal url and then redirect the the paypal page with all posted data populated in that page. not just response.redirect("https://www.paypal.com/cgi-bin/webscr") because this url itself does not show any data.
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 20

Expert Comment

by:informaniac
ID: 34994582
So as of now wht is hapening? 2ndly r u askin how to update the paypal page from ur page? Tht's not possible.
0
 
LVL 6

Author Comment

by:viola123
ID: 34994645
Hi, informaniac:

below is a html page, clicking the submit button will post all hidden fileds data to https://www.paypal.com/cgi-bin/webscr and the page will be directed to that paypal page and all posted data is displayed in that paypal page.

my question is how to achieve this using asp.net server-side button click event. yes, two things:
1. post data
2. redirect to the page and display posted data in that page

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick"/>
<input type="hidden" name="business" value="yingtuo@yahoo.com"/>
<input type="hidden" name="lc" value="AU"/>
<input type="hidden" name="item_name" value="Order Item 100000">
<input type="hidden" name="amount" value="100.00"/>
<input type="hidden" name="currency_code" value="AUD"/>
<input type="hidden" name="button_subtype" value="services"/>
<input type="hidden" name="no_note" value="0"/>
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest"/>
<input type="image" src="https://www.paypal.com/en_AU/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online."/>
<img alt="" border="0" src="https://www.paypal.com/en_AU/i/scr/pixel.gif" width="1" height="1"/>
</form>
0
 
LVL 10

Accepted Solution

by:
John Claes earned 500 total points
ID: 34995063
Then we need 2 things

Question 1 : Post data :
(See answer of agarwalrahul)
You need to add the Id attribute and runat="server" attribute to every field you'll need to be posted.
After clicking the Button these fields will post their value towards the server.

Question 2
At server Side you do what you need to do to your database
But then You need to Redirect(using post /Push Values?)


Example (using answer of Agarwalrahul for ease ;-) )


Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
          insert into DB
         dim Url as string
         Url ="https://www.paypal.com/cgi-bin/webscr?"
         Url =Url & "business=" & business.value
         Url =Url & "&lc=" & lc.value
         Url =Url & "&item_name=" & item_name.value
         response.redirect(Url )

regards
poor beggar
0
 

Expert Comment

by:pavan_kumar_kokkiragedda
ID: 34995862
Hi,
Instead of using the "postbackurl" attribute, you can go for a button click event,do the db changes and then redirect to the desired page using Response.Redirect.

0
 
LVL 6

Author Comment

by:viola123
ID: 35003628
Hi,

this url display only login page without post data. if you simply use response.redirect(), it could not display those posted data in destination url.

I don't want to post data and hit the login page by using response.redirect(). I need those posted data page displayed in the destination url.

using 'POST' and then use 'GET' does not work
0
 

Assisted Solution

by:pavan_kumar_kokkiragedda
pavan_kumar_kokkiragedda earned 500 total points
ID: 35004449
In that case,
you can try going for a java script function that does the db changes  using ajax, and set this function as the value for the "OnClientClick" event of the button.

hope this helps

Regards,
Pavan
0
 
LVL 6

Author Closing Comment

by:viola123
ID: 35412676
thanks all for your reply
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question