Create dynamic data and post to a server.
-
I'm using VB .NET I need to have the customer click a button and raise an event. I then need to process some information and prepare values to send. I then need to create the example below (or equivalent) and send it in the VB .NET event. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click I can get here 'code goes here prepare dynamic values. (I can do this part) Taxes = Cost * 8.75 Price = Shipping + Cost then create the code below and post it? (this next part is what I need PostIt = <FORM ACTION="https://www.whatever.com/cgi-bin/webscr" _METHOD="post" TARGET="XYZ" ID="Form2"> PostIt += <INPUT TYPE="hidden" VALUE= Price NAME=amount> PostIt += <INPUT TYPE="hidden" VALUE= Taxes NAME=TaxAmount> PostIt += <INPUT TYPE="hidden" VALUE= Shipping NAME=Ship> PostIt += </form> PostIt Now somehow post it to the server End Sub Below is the cut and paste code I got from the server that the data will be posted too. (I edited it with the databinder.eval)the code below works correct. <FORM ACTION="https://www.whatever.com/cgi-bin/webscr" METHOD="post" TARGET="XYZ" ID="Form2"> <INPUT TYPE="hidden" VALUE="_cart" NAME="cmd"> <INPUT TYPE="hidden" VALUE="[email protected]" NAME="business" <INPUT TYPE="hidden" VALUE='<%# DataBinder.Eval(ctype(Container, DataListItem).DataItem, "Name") %>>' NAME=item_name> <INPUT TYPE="hidden" VALUE='<%# DataBinder.Eval(CType(Container, DataListItem).DataItem, "ItemID") %>' NAME=item_number> <INPUT TYPE="hidden" VALUE='<%# DataBinder.Eval(CType(Container, DataListItem).DataItem, "RetailPrice") %>' NAME=amount> <INPUT TYPE="hidden" VALUE="1" NAME="no_note"> <INPUT TYPE="hidden" VALUE="USD" NAME="currency_code"> P align="right"> <INPUT TYPE="image" HEIGHT="23" ALT="xxx" WIDTH="87" SRC="https://www.me.com/images/x-click-but22.gif" BORDER="0" NAME="I1"> <INPUT TYPE="hidden" VALUE="1" NAME="add"></P> /FORM>
-
Answer:
Easy! Use the WebRequest class in .NET to prepare a POST request: ' Create our new form-encoded post ' This needs to look like "cmd=_cart&[email protected]&x=y&..." Dim PostString as New String PostString += "cmd=" + UrlEncode( "_cart" ) PostString += "&" PostString += "business=" + UrlEncode( "[email protected]" ) PostString += "&" PostString += "x=" + UrlEncode( "something else" ) etc... ' Create a new WebRequest Dim req as HttpWebRequest = WebRequest.Create( "https://www.whatever.com/cgi-bin/webscr" ) ' Make it a post req.Method = "POST" req.AddHeader( "Content-Type", "application/x-www-form-encoded" ) req.ContentLength = PostString.Length ' Send the post data Dim sw as StreamWriter = new StreamWriter( req.GetRequestStream() ) sw.WriteLine( PostString ) ' Read the response Dim sr as StreamReader = new StreamReader( req.GetResponseStream() ) Dim ResponseText = sr.ReadToEnd() The response from the server will be in ResponseText for you to use if you need it. Let me know if you need more.
tonymast-ga at Google Answers Visit the source
Related Q & A:
- How to create dynamic function in javascript?Best solution by Stack Overflow
- How to send data from device to remote server?Best solution by Stack Overflow
- How to create dynamic animations?Best solution by Yahoo! Answers
- How to create dynamic php pages?Best solution by Stack Overflow
- What are some phones for Verizon Wireless without a data plan or with a cheap data plan?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.