Dear Experts!
I am very new to asp programming. I'm trying to process a linkpointAPI order using my asp.net page. Right now my issue is that every time my page loads (even after the postback) I need to take all the values that the user fills into the fields and I need to pass it to my linkpointapi thing. Anyways, here is my code part, which does not run. It crashes on the fillinformfields, saying that fld_bcompany is equal to nothing. That is why I cannot read the text property on the field. Based on the following code, Experts, what am I doing wrong?
Namespace LinkPointAPI_vb
Public Class Order
Inherits LinkPointTxn_Page
''Inherits System.Web.UI.Page
Dim flagUserCreated As Boolean = False
'Protected WithEvents fld_bname As System.Web.UI.WebControls.
TextBox = Application.Item("fld_bnam
e")
'Protected fld_bcompany As System.Web.UI.WebControls.
TextBox
Protected fld_baddr1 As System.Web.UI.WebControls.
TextBox
Protected fld_bcity As System.Web.UI.WebControls.
TextBox
Protected fld_bstate As System.Web.UI.WebControls.
TextBox
Protected fld_bzip As System.Web.UI.WebControls.
TextBox
Protected fld_bphone As System.Web.UI.WebControls.
TextBox
Protected fld_saddr1 As System.Web.UI.WebControls.
TextBox
Protected fld_scity As System.Web.UI.WebControls.
TextBox
Protected fld_sstate As System.Web.UI.WebControls.
TextBox
Protected fld_szip As System.Web.UI.WebControls.
TextBox
Public Sub FillInFormFields()
Session.Item("bcompany") = Me.fld_bcompany.text
End Sub
Public Sub OnCreatingUser(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.
LoginCance
lEventArgs
) Handles CreateUserWizard1.Creating
User
FillInFormFields()
ParseFormData()
ProcessOrder()
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If IsPostBack Then
FillInFormFields()
'Parse form data
ParseFormData()
'process(Order)
ProcessOrder()
End If
End Sub
Private Sub ProcessOrder()
' create order
Dim op As LinkPointTransaction.LPOrd
erPart
Dim order As LinkPointTransaction.LPOrd
erPart
order = LinkPointTransaction.LPOrd
erFactory.
createOrde
rPart("ord
er")
' create a part we will use to build the order
op = LinkPointTransaction.LPOrd
erFactory.
createOrde
rPart()
' Build 'orderoptions'
op.put("ordertype", "SALE")
' set transaction result
op.put("result", Request.Form("result"))
' add 'orderoptions to order
order.addPart("orderoption
s", op)
' Build 'transactiondetails'
op.clear()
op.put("transactionorigin"
, Request.Form("origin"))
' add 'transactiondetails to order
order.addPart("transaction
details", op)
' Build 'merchantinfo'
op.clear()
op.put("configfile", configfile)
' add 'merchantinfo to order
order.addPart("merchantinf
o", op)
' Build 'payment'
op.clear()
op.put("subtotal", Request.Form("subtotal"))
op.put("tax", Request.Form("tax"))
op.put("shipping", Request.Form("shipping"))
op.put("chargetotal", Request.Form("total"))
' add 'payment to order
order.addPart("payment", op)
' Build 'creditcard'
op.clear()
op.put("cardnumber", cardnumber)
op.put("cardexpmonth", expmonth)
op.put("cardexpyear", expyear)
op.put("cvmvalue", cvmvalue)
op.put("cvmindicator", cvmindicator)
' add 'creditcard to order
order.addPart("creditcard"
, op)
' Build 'billing'
op.clear()
op.put("name", bname)
op.put("company", bcompany)
op.put("address1", baddr1)
op.put("address2", baddr2)
op.put("city", bcity)
op.put("state", bstate)
' Required for AVS. If not provided,
' transactions will downgrade.
op.put("zip", bzip)
op.put("addrnum", baddrnum)
op.put("country", bcountry)
op.put("phone", bphone)
op.put("fax", bfax)
op.put("email", bemail)
' add 'billing to order
order.addPart("billing", op)
' Build 'shipping'
op.clear()
op.put("name", sname)
op.put("address1", saddr1)
op.put("address2", saddr2)
op.put("city", scity)
op.put("state", sstate)
op.put("zip", szip)
op.put("country", scountry)
' Create some parts we use to build order items
Dim items, item, options As LinkPointTransaction.LPOrd
erPart
items = LinkPointTransaction.LPOrd
erFactory.
createOrde
rPart()
item = LinkPointTransaction.LPOrd
erFactory.
createOrde
rPart()
options = LinkPointTransaction.LPOrd
erFactory.
createOrde
rPart()
' build 'item'
item.put("id", Request.Form("id2"))
item.put("description", Request.Form("desc2"))
item.put("quantity", Request.Form("qty2"))
item.put("price", Request.Form("price2"))
item.put("serial", Request.Form("serial2"))
' build item's options
op.clear()
op.put("name", "Color")
op.put("value", Request.Form("Color"))
options.addPart("option", op, 1)
op.clear()
op.put("name", "Size")
op.put("value", Request.Form("Size"))
options.addPart("option", op, 2)
' add 'options' to item
item.addPart("options", options)
' add 'item' to 'items' collection
items.addPart("item", item)
' add 'items' to order
order.addPart("items", items)
' add notes
op.clear()
op.put("comments", comments)
op.put("referred", referred)
order.addPart("notes", op)
' create transaction object
LPTxn = New LinkPointTransaction.LinkP
ointTxn()
' get outgoing XML from 'order' object
Dim outXml As String = order.toXML()
' Call LPTxn
Dim resp As String = LPTxn.send(keyfile, host, port, outXml)
'Store transaction data on Session and redirect
Session("outXml") = outXml
Session("resp") = resp
Server.Transfer("status.as
px")
End Sub
Private Sub AddUserExtraInfo()
Dim UserNameTextBox As TextBox = CreateUserWizardStep2.Cont
entTemplat
eContainer
.FindContr
ol("UserNa
me")
Dim myDataSource As SqlDataSource = CreateUserWizardStep2.Cont
entTemplat
eContainer
.FindContr
ol("Insert
ExtraInfo"
)
Dim User As MembershipUser = Membership.GetUser(UserNam
eTextBox.T
ext)
Dim UserGUID As Object = User.ProviderUserKey
myDataSource.InsertParamet
ers.Add("U
serID", UserGUID.ToString())
myDataSource.Insert()
End Sub
Public Sub CreateWizard1_OnUserCreate
d(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedU
ser
Dim userInfo As MembershipUser = Membership.GetUser(CreateU
serWizard1
.UserName)
'' Static flagUserCreated As Boolean = False
If flagUserCreated = False Then
userInfo.IsApproved = True
Membership.UpdateUser(user
Info)
Roles.AddUserToRole(Create
UserWizard
1.UserName
, "Users")
AddUserExtraInfo()
flagUserCreated = True
End If
End Sub
'Private Sub CreateWizard1_OnCreatingUs
er(ByVal send As Object, ByVal e As System.Web.UI.Webcontrols.
LoginCance
lEventArgs
) Handles CreateUserWizard1.Creating
User
'Server.Transfer("
https://www.linkpointcentral.com/lpc/servlet/lppay")
'End Sub
' Public Sub CreateWizard1_OnCreatingUs
er(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.
LoginCance
lEventArgs
) Handles CreateUserWizard1.Creating
User
'Me.GetPostBackClientEvent
(Me.Create
UserWizard
1.Controls
().Item("L
PPay"),
'Dim aControl As System.Web.UI.WebControls.
Button = CreateUserWizard1.contr
' Dim result$ = ClientScript.GetPostBackEv
entReferen
ce(Me.Crea
teUserWiza
rd1.Contro
ls().Item(
"LPPay"), "
https://www.linkpointcentral.com/lpc/servlet/lppay")
'Dim acontrol As System.Web.UI.WebControls.
IButtonCon
trol = Me.CreateUserWizard1.Contr
ols().Item
("LPPay")
' acontrol.PostBackUrl = "
https://www.linkpointcentral.com/lpc/servlet/lppay"
'End Sub
Protected Sub fld_bcompany_TextChanged(B
yVal sender As Object, ByVal e As System.EventArgs)
Stop
End Sub
End Class
End Namespace
<%@ Page Language="VB"
MasterPageFile="~/MasterPa
ge.master"
AutoEventWireup="false"
CodeFile="Order.aspx.vb"
Inherits="LinkPointAPI_vb.
Order"
title="Create User and Order Now"
ClassName="Order"%>
<asp:Content ID="Content1" ContentPlaceHolderID="Cont
entPlaceHo
lder1" Runat="Server">
<form id="form1" runat="server" method="post">
<div>
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" BackColor="#FFFBD6" BorderColor="#FFDFAD" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" Width="448px" OnCreatedUser="CreateWizar
d1_OnUserC
reated">
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep2"
runat="server">
<ContentTemplate>
<table style="width: 446px">
<tr>
<th>Billing Information</th>
</tr>
<tr>
<td>Billing Company:</td>
<td style="width: 334px">
<asp:TextBox runat="server" ID="fld_bcompany" MaxLength="50" Text="Z2 marketing" OnTextChanged="fld_bcompan
y_TextChan
ged"/>
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
31" ControlToValidate="fld_bco
mpany"
ErrorMessage="Your Company's Name is required." />
</td>
</tr>
<tr>
<td>Billing Name</td>
<td style="width: 334px">
<asp:TextBox runat="server" ID="fld_bname" MaxLength="50" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
30" ControlToValidate="fld_bna
me" ErrorMessage="Your Name is Required." />
</td>
</tr>
<tr>
<td>Billing Address:</td>
<td style="width: 334px">
<asp:TextBox runat="server" ID="fld_baddr1" MaxLength="50" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
1" ControlToValidate="fld_bad
dr1"
ErrorMessage="Billing Address is required." />
</td>
</tr>
<tr>
<td>Billing City:</td>
<td style="width: 334px">
<asp:TextBox runat="server" ID="fld_bcity" MaxLength="50" Columns="15" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
2" ControlToValidate="fld_bci
ty"
ErrorMessage="Billing City is required." />
</td>
</tr>
<tr>
<td>Billing State:</td>
<td style="width: 334px">
<asp:TextBox runat="server" ID="fld_bstate" MaxLength="25" Columns="10" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
3" ControlToValidate="fld_bst
ate"
ErrorMessage="Billing State is required." />
</td>
</tr>
<tr>
<td>Billing Zip:</td>
<td style="width: 334px">
<asp:TextBox runat="server" ID="fld_bzip" MaxLength="10" Columns="10" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
4" ControlToValidate="fld_bzi
p"
ErrorMessage="Billing Zip is required." />
</td>
</tr>
<tr>
<td>Billing Phone:</td>
<td style="width: 334px">
<asp:TextBox runat="server" ID="fld_bphone" MaxLength="50" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
32" ControlToValidate="fld_bph
one"
ErrorMessage="Billing Phone is required." />
</td>
</tr>
</table>
<table>
<tr>
<th style="width: 157px">Select Your Product from the Menu Below</th>
</tr>
<tr>
<td style="width: 157px; height: 31px;">Product Selection:</td>
<td style="height: 31px">
<asp:DropDownList runat="server" id="fld_chargetotal" Height="69px" >
<asp:ListItem Selected="True" Value="39.95">1 Month Credit Watch Subscription - $39.95</asp:ListItem>
<asp:ListItem Value="99.95">3 Month Credit Watch Subscription - $99.95</asp:ListItem>
<asp:ListItem Value="199.95">6 Month Credit Watch Subscription - $199.95</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
<table>
<tr>
<th>Shipping Information</th>
</tr>
<tr>
<td>Shipping Address:</td>
<td>
<asp:TextBox runat="server" ID="fld_saddr1" MaxLength="50" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
5" ControlToValidate="fld_sad
dr1"
ErrorMessage="Shipping Address is required." />
</td>
</tr>
<tr>
<td>Shipping City:</td>
<td>
<asp:TextBox runat="server" ID="fld_scity" MaxLength="50" Columns="15"/>
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
6" ControlToValidate="fld_sci
ty"
ErrorMessage="Shipping City is required." />
</td>
</tr>
<tr>
<td>Shipping State:</td>
<td>
<asp:TextBox runat="server" ID="fld_sstate" MaxLength="25" Columns="10" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
7" ControlToValidate="fld_sst
ate"
ErrorMessage="Shipping State is required." />
</td>
</tr>
<tr>
<td>Shipping Zip:</td>
<td>
<asp:TextBox runat="server" ID="fld_szip" MaxLength="10" Columns="10" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
8" ControlToValidate="fld_szi
p"
ErrorMessage="Shipping Zip is required." />
</td>
</tr>
</table>
<table style="width: 443px">
<tr>
<th style="width: 114px">Payment Information</th>
</tr>
<tr>
<td style="width: 114px">Credit Card Type</td>
<td>
<asp:DropDownList runat="server" id="fld_cctype" Height="69px" >
<asp:ListItem Selected="True" Value="V">Visa</asp:ListIt
em>
<asp:ListItem Value="M">Mastercard</asp:
ListItem>
<asp:ListItem Value="A">American Express</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="height: 42px">Credit Card Number</td>
<td style="height: 42px">
<asp:TextBox runat="server" ID="fld_cardnumber" MaxLength="16" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
33" ControlToValidate="fld_car
dnumber" ErrorMessage="Your Credit Card Information in Required"/>
</td>
</tr>
<tr>
<td style="height: 42px">Expiration Date</td>
<td style="height: 42px">
<asp:TextBox runat="server" ID="fld_expmonth" Width="3" MaxLength="2"/>
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
34" ControlToValidate="fld_exp
month" ErrorMessage="Your 2 digit Experiation Month is required"/>
/ <asp:TextBox runat="server" ID="fld_expyear" Width="3" MaxLength="4"/>
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
15" ControlToValidate="fld_exp
year" ErrorMessage="Your 4 digit Experiation Year is required"/>
</td>
</tr>
</table>
<table>
<tr>
<th>User Information</th>
</tr>
<tr>
<td>Username:</td>
<td style="width: 337px">
<asp:TextBox runat="server" ID="UserName" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
9" ControlToValidate="UserNam
e"
ErrorMessage="Username is required." />
</td>
</tr>
<tr>
<td>Password:</td>
<td style="width: 337px">
<asp:TextBox runat="server" ID="Password" TextMode="Password" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
10" ControlToValidate="Passwor
d"
ErrorMessage="Password is required." />
</td>
</tr>
<tr>
<td>Confirm Password:</td>
<td style="width: 337px">
<asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
13" ControlToValidate="Confirm
Password"
ErrorMessage="Confirm Password is required." />
</td>
</tr>
<tr>
<td>Email:</td>
<td style="width: 337px">
<asp:TextBox runat="server" ID="Email" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
11" ControlToValidate="Email"
ErrorMessage="Email is required." />
</td>
</tr>
<tr>
<td>Question:</td>
<td style="width: 337px">
<asp:TextBox runat="server" ID="Question" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
12" ControlToValidate="Questio
n"
ErrorMessage="Question is required." />
</td>
</tr>
<tr>
<td>Answer:</td>
<td style="width: 337px">
<asp:TextBox runat="server" ID="Answer" />
<asp:RequiredFieldValidato
r runat="server" ID="RequiredFieldValidator
14" ControlToValidate="Answer"
ErrorMessage="Answer is required." />
</td>
</tr>
<tr>
<td colspan="2">
<asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password
"
ControlToValidate="Confirm
Password" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."></asp:CompareValid
ator>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></
asp:Litera
l>
</td>
</tr>
</table>
<asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDB
%>"
InsertCommand="INSERT INTO [UserOrderInfo] ([UserId], [bname], [bcompany, [baddr1], [bcity], [bzip], [phone], [chargetotal], [cctype], [cardnumber] [expmonth], [expyear], [saddr1], [scity], [sstate], [szip]) VALUES (@UserId, @bname, @bcompany, @baddr1, @bcity, @bzip, @phone, @chargetotal, @cctype, @cardnumber, @expmonth, @expyear, @saddr1, @scity, @sstate, @szip)"
ProviderName="<%$ ConnectionStrings:ASPNETDB
.ProviderN
ame %>">
<InsertParameters>
<asp:ControlParameter Name="bname" Type="String" ControlID="BuyerName" PropertyName="Text" />
<asp:ControlParameter Name="bcompany" Type="String" ControlID="BuyerCompany" PropertyName="Text" />
<asp:ControlParameter Name="baddr1" Type="String" ControlID="baddr1" PropertyName="Text" />
<asp:ControlParameter Name="bcity" Type="String" ControlID="bcity" PropertyName="Text" />
<asp:ControlParameter Name="bstate" Type="String" ControlID="bstate" PropertyName="Text" />
<asp:ControlParameter Name="bzip" Type="String" ControlID="bzip" PropertyName="Text" />
<asp:ControlParameter Name="phone" Type="String" ControlID="phone" PropertyName="Text" />
<asp:ControlParameter Name="chargetotal" Type="Decimal" ControlID="chargetotal" PropertyName="Text" />
<asp:ControlParameter Name="cctype" Type="String" ControlID="cctype" PropertyName="Text" />
<asp:ControlParameter Name="cardnumber" Type="String" ControlID="cardnumber" PropertyName="Text" />
<asp:ControlParameter Name="expmonth" Type="String" ControlID="expmonth" PropertyName="Text" />
<asp:ControlParameter Name="expyear" Type="String" ControlID="expyear" PropertyName="Text" />
<asp:ControlParameter Name="saddr1" Type="String" ControlID="saddr1" PropertyName="Text" />
<asp:ControlParameter Name="scity" Type="String" ControlID="scity" PropertyName="Text" />
<asp:ControlParameter Name="sstate" Type="String" ControlID="sstate" PropertyName="Text" />
<asp:ControlParameter Name="szip" Type="String" ControlID="szip" PropertyName="Text" />
</InsertParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:CreateUserWizardStep
>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
<ContentTemplate>
<table border="0" style="font-size: 100%; width: 448px; font-family: Verdana; background-color: #fffbd6">
<tr>
<td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #990000">
Complete</td>
</tr>
<tr>
<td>
Your account has been successfully created.</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="ContinueButton" runat="server" BackColor="White" BorderColor="#CC9966"
BorderStyle="Solid" BorderWidth="1px" CausesValidation="False" CommandName="Continue"
Font-Names="Verdana" ForeColor="#990000" Text="Continue" ValidationGroup="CreateUse
rWizard1" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
<NavigationButtonStyle BackColor="White" BorderColor="#CC9966" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" ForeColor="#990000" />
<HeaderStyle BackColor="#FFCC66" BorderColor="#FFFBD6" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" Font-Size="0.9em" ForeColor="#333333" HorizontalAlign="Center" />
<CreateUserButtonStyle BackColor="White" BorderColor="#CC9966" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" ForeColor="#990000" />
<ContinueButtonStyle BackColor="White" BorderColor="#CC9966" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" ForeColor="#990000" />
<SideBarStyle BackColor="#990000" Font-Size="0.9em" VerticalAlign="Top" />
<TitleTextStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<SideBarButtonStyle ForeColor="White" />
<FinishNavigationTemplate>
<asp:Button ID="FinishPreviousButton" runat="server" BackColor="White" BorderColor="#CC9966"
BorderStyle="Solid" BorderWidth="1px" CausesValidation="False" CommandName="MovePrevious"
Font-Names="Verdana" ForeColor="#990000" Text="Previous" />
<asp:Button ID="FinishButton" runat="server" BackColor="White" BorderColor="#CC9966"
BorderStyle="Solid" BorderWidth="1px" CommandName="MoveComplete"
Font-Names="Verdana"
ForeColor="#990000" Text="Finish" />
</FinishNavigationTemplate
>
</asp:CreateUserWizard>
</div>
</form>
</asp:Content>
Thank you for all your help.. this is very important to me!
~Michael