Question

How do I access the text out of an asp textbox in my code page for the page it's attached to?

Asked by: JeffreyDurham

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_bname")
        '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.LoginCancelEventArgs) Handles CreateUserWizard1.CreatingUser
            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.LPOrderPart
            Dim order As LinkPointTransaction.LPOrderPart

            order = LinkPointTransaction.LPOrderFactory.createOrderPart("order")
            ' create a part we will use to build the order
            op = LinkPointTransaction.LPOrderFactory.createOrderPart()

            ' Build 'orderoptions'
            op.put("ordertype", "SALE")
            ' set transaction result
            op.put("result", Request.Form("result"))
            ' add 'orderoptions to order
            order.addPart("orderoptions", op)
            ' Build 'transactiondetails'
            op.clear()
            op.put("transactionorigin", Request.Form("origin"))
            ' add 'transactiondetails to order
            order.addPart("transactiondetails", op)
            ' Build 'merchantinfo'
            op.clear()
            op.put("configfile", configfile)
            ' add 'merchantinfo to order
            order.addPart("merchantinfo", 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.LPOrderPart
            items = LinkPointTransaction.LPOrderFactory.createOrderPart()
            item = LinkPointTransaction.LPOrderFactory.createOrderPart()
            options = LinkPointTransaction.LPOrderFactory.createOrderPart()
            '  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.LinkPointTxn()

            ' 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.aspx")
        End Sub

        Private Sub AddUserExtraInfo()
            Dim UserNameTextBox As TextBox = CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName")
            Dim myDataSource As SqlDataSource = CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo")
            Dim User As MembershipUser = Membership.GetUser(UserNameTextBox.Text)
            Dim UserGUID As Object = User.ProviderUserKey

            myDataSource.InsertParameters.Add("UserID", UserGUID.ToString())
            myDataSource.Insert()
        End Sub


        Public Sub CreateWizard1_OnUserCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
            Dim userInfo As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
            '' Static flagUserCreated As Boolean = False
            If flagUserCreated = False Then
                userInfo.IsApproved = True
                Membership.UpdateUser(userInfo)
                Roles.AddUserToRole(CreateUserWizard1.UserName, "Users")
                AddUserExtraInfo()
                flagUserCreated = True
            End If
        End Sub
        'Private Sub CreateWizard1_OnCreatingUser(ByVal send As Object, ByVal e As System.Web.UI.Webcontrols.LoginCancelEventArgs) Handles CreateUserWizard1.CreatingUser
        'Server.Transfer("https://www.linkpointcentral.com/lpc/servlet/lppay")
        'End Sub

        ' Public Sub CreateWizard1_OnCreatingUser(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs) Handles CreateUserWizard1.CreatingUser
        'Me.GetPostBackClientEvent(Me.CreateUserWizard1.Controls().Item("LPPay"),
        'Dim aControl As System.Web.UI.WebControls.Button = CreateUserWizard1.contr


        ' Dim result$ = ClientScript.GetPostBackEventReference(Me.CreateUserWizard1.Controls().Item("LPPay"), "https://www.linkpointcentral.com/lpc/servlet/lppay")
        'Dim acontrol As System.Web.UI.WebControls.IButtonControl = Me.CreateUserWizard1.Controls().Item("LPPay")
        '   acontrol.PostBackUrl = "https://www.linkpointcentral.com/lpc/servlet/lppay"
        'End Sub

        Protected Sub fld_bcompany_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
            Stop
        End Sub
    End Class

End Namespace

<%@ Page Language="VB"
MasterPageFile="~/MasterPage.master"
AutoEventWireup="false"
CodeFile="Order.aspx.vb"
Inherits="LinkPointAPI_vb.Order"
title="Create User and Order Now"
ClassName="Order"%>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" 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="CreateWizard1_OnUserCreated">
            <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_bcompany_TextChanged"/>
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator31" ControlToValidate="fld_bcompany"
                                     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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator30" ControlToValidate="fld_bname" 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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="fld_baddr1"
                                     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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="fld_bcity"
                                     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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator3" ControlToValidate="fld_bstate"
                                     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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator4" ControlToValidate="fld_bzip"
                                     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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator32" ControlToValidate="fld_bphone"
                                     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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator5" ControlToValidate="fld_saddr1"
                                     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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator6" ControlToValidate="fld_scity"
                                     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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator7" ControlToValidate="fld_sstate"
                                     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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator8" ControlToValidate="fld_szip"
                                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:ListItem>
                                 <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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator33" ControlToValidate="fld_cardnumber" 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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator34" ControlToValidate="fld_expmonth" ErrorMessage="Your 2 digit Experiation Month is required"/>
                     / <asp:TextBox runat="server" ID="fld_expyear" Width="3" MaxLength="4"/>
                     <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator15" ControlToValidate="fld_expyear" 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:RequiredFieldValidator runat="server" ID="RequiredFieldValidator9" ControlToValidate="UserName"
                                    ErrorMessage="Username is required." />
                            </td>
                        </tr>
                        <tr>
                            <td>Password:</td>
                            <td style="width: 337px">
                                <asp:TextBox runat="server" ID="Password" TextMode="Password" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator10" ControlToValidate="Password"
                                    ErrorMessage="Password is required." />
                            </td>
                        </tr>
                        <tr>
                            <td>Confirm Password:</td>
                            <td style="width: 337px">
                                <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator13" ControlToValidate="ConfirmPassword"
                                    ErrorMessage="Confirm Password is required." />
                            </td>
                        </tr>
                        <tr>
                            <td>Email:</td>
                            <td style="width: 337px">
                                <asp:TextBox runat="server" ID="Email" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator11" ControlToValidate="Email"
                                    ErrorMessage="Email is required." />
                            </td>
                        </tr>
                        <tr>
                            <td>Question:</td>
                            <td style="width: 337px">
                                <asp:TextBox runat="server" ID="Question" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator12" ControlToValidate="Question"
                                    ErrorMessage="Question is required." />
                            </td>
                        </tr>
                        <tr>
                            <td>Answer:</td>
                            <td style="width: 337px">
                                <asp:TextBox runat="server" ID="Answer" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator14" ControlToValidate="Answer"
                                    ErrorMessage="Answer is required." />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                 <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                                        ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."></asp:CompareValidator>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                            </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.ProviderName %>">
                        <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="CreateUserWizard1" />
                                </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

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2007-08-09 at 15:07:27ID22753421
Topics

Programming for ASP.NET

,

Microsoft Visual Basic.Net

Participating Experts
4
Points
500
Comments
9

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Storing and Changing Countries
    I have a list of all the countries in the world, but what I would love is the ASP to allow users to change their country. Adding it is easy! As there are hundreds of countries in the list it a huge task to check which country the user has selected in a drop down box....the a...
  2. ASP Vs JSP/Servlet!!!
    Hi, What is the strength of using ASP when comparing with JSP/Servlet? I have read some artciles which had pointed out the strength of using JSP/Servlet and the weakness of ASP. Is there any strength existed in using ASP? Thanks!!!
  3. Writing an ASP website for American and Asian Markets?
    I am writing a website that will be used by both American and Asian markets. My concern is over the use of double-byte characters in the Asian market. What sort of things do I need to do in order to ensure my site is usable in the Asian market (specifically, Korea). Just as ...
  4. Conditional Validation (Country/State/City)
    i have a 2 combobox and a 1 textbox and a search button 1) country combobox 2) state combobox 3) textbox when user click on search button without selecting (country/state/city(textbox) then validation should fire and ask to enter country/state/city (if the user select "...
  5. Access uk american date format problem
    I am using dreamweaver to insert a date into access. It seems that it will only insert an american format I use <%session.lcid=2057%> at the top of the page The access date field is set to Date/time MediumDate When I insert a record via dreamweaver it shows in the db ...
  6. Div over textbox, can't select the textbox as used to!
    I have a div over all of the forms inside of a asp.net page. All form are clickable but only the textbox and the textarea aren't. if i want to click in the textbox i don't get the prompt in the controls. My div looks like this: <div style="position:absolute; top:1...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: QPRPosted on 2007-08-09 at 16:00:14ID: 19666682

the quick answer to your question - I admit to not reading all that code!
In your code behind in the event handler...

dim myVar as string = txtTextboxName.text

 

by: JeffreyDurhamPosted on 2007-08-09 at 16:13:27ID: 19666729

Yeah, I wouldn't have posted all that except I'm not sure where the problem lies. It's like the code section isn't recognising the fields on the behind page. I'm not sure why, but when I try to do txtTextboxName.text, it errs out, as if it can't find the field. If you check the locals window you can see that fldbcompany (for example) has a value of nothing at runtime. Essentially the field doesn't exist as far as the program is concerned. This is why I can't read the value out of it which I need.

This is where I define the box (this is inside the LinkPointTxn_Page)

<asp:TextBox runat="server" ID="fld_bcompany" MaxLength="50" Text="Z2 marketing" OnTextChanged="fld_bcompany_TextChanged"/>

Here is the beginning of the order.aspx, where I try your suggestion, using the
    dim myVar as string = txtTextboxName.text

Namespace LinkPointAPI_vb
    Public Class Order
        Inherits LinkPointTxn_Page
        ''Inherits System.Web.UI.Page
        Dim flagUserCreated As Boolean = False
        'Protected fld_bcompany As System.Web.UI.WebControls.TextBox

        Public Sub FillInFormFields()
            Session.Item("bcompany") = Me.fld_bcompany.text  <--- ERRS OUT HERE (Says fld_bcompany=>Nothing)
        End Sub

 

by: HavaganPosted on 2007-08-09 at 16:32:14ID: 19666815

According to your code you've commented out the reference to fld_bcompany text box.

        'Protected fld_bcompany As System.Web.UI.WebControls.TextBox <--- commented (see the comma at char pos 1?)
        Protected fld_baddr1 As System.Web.UI.WebControls.TextBox
        Protected fld_bcity As System.Web.UI.WebControls.TextBox

Try uncommenting that line.

 

by: JeffreyDurhamPosted on 2007-08-09 at 16:40:12ID: 19666847

Havagan:

I removed the comment as you recommended, now the code would be:

 Protected fld_bcompany As System.Web.UI.WebControls.TextBox

The error is still there, and it is still erring on the same line. The error message is:
'Object reference not set to an instance of an object'

):

 

by: TSmoothPosted on 2007-08-09 at 17:17:36ID: 19666964

The reason it doesn't recognize it is because your controls are in wizard steps of the create user wizard control. This means they are part of a template which means you cannot directly reference them like you are. What you must do is use the Wizard control's reference, access the proper step on which the control is and then use the "FindControl()" method of that wizard step to get a reference to the control.

For your code pasted, as an example of how to get a reference to the text box you mentioned:
Dim fld_bcompany As TextBox = DirectCast(CreateUserWizard1.WizardSteps(0).FindControl("fld_bcompany"), TextBox)

In the above code, since your control of interest is in the first wizard step (Index of 0), we use WizardSteps(0), and then use the find control method to find a control with id "fld_bcompany" on this wizard step.

You can then access the properties of fld_bcompany such as:
Session("bcompany") = fld_bcompany.Text

You will need to do the same kind of thing for your other controls in the wizard steps. The discussion as to why you have to access template controls like this is kind of lengthy. I suggest you look up some tutorials on the subject and you can even more specifically look up tutorials on customizing the createuser wizard.

 

by: SystemExpertPosted on 2007-08-09 at 23:08:53ID: 19667967

Hi,

Can you tell me when you reach @
Public Sub FillInFormFields()
            Session.Item("bcompany") = Me.fld_bcompany.text                  ' HERE
End Sub
Just set debug the code
What is the value for
fld_bcompany.text                  

also plz tell what do you mean by Stop in following code

Protected Sub fld_bcompany_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
            Stop
End Sub

 

by: JeffreyDurhamPosted on 2007-08-10 at 09:42:39ID: 19671464

Tsmooth, I was pretty sure you were right, sounded right anyways, but when I try executing the code you recommended to me to reach the textbox:

Public Sub FillInFormFields()
            Dim anyFld As Object
            anyFld = CreateUserWizard1.WizardSteps(0).FindControl("fld_bcompany")
            Session.Item("bcompany") = anyFld.Text
            'Session.Item("bcompany") = Me.fld_bcompany.Text
        End Sub

it gives me this error:

NullReferenceException Was unhandled by User Code.
Object variable or With block variable not set.

What am I doing wrong?
~Michael

 

by: TSmoothPosted on 2007-08-10 at 10:23:55ID: 19671844

What line of code is giving you that error? Keep in mind that you need to cast the object to a textbox to expose the .Text property. Change your code to this:

Public Sub FillInFormFields()
            Dim anyFld As TextBox
            anyFld = DirectCast(CreateUserWizard1.WizardSteps(0).FindControl("fld_bcompany"), TextBox)
            Session.Item("bcompany") = anyFld.Text
End Sub

 

by: JeffreyDurhamPosted on 2007-08-10 at 10:28:27ID: 19671881

TSmooth...

I tried your solution and I was able to get it to work with a few alterations.  This is what I ended up doing...

        Public Sub FillInFormFields()
            Dim anyFld As Object
            anyFld = CreateUserWizardStep2.ContentTemplateContainer.FindControl("fld_bcompany")
            'anyFld = CreateUserWizard1.WizardSteps(0).FindControl("fld_bcompany")
            Session.Item("bcompany") = anyFld.Text
            anyFld = CreateUserWizardStep2.ContentTemplateContainer.FindControl("fld_bname")
            Session.Item("bname") = anyFld.Text
            anyFld = CreateUserWizardStep2.ContentTemplateContainer.FindControl("fld_baddr1")
            Session.Item("baddr1") = anyFld.Text
            anyFld = CreateUserWizardStep2.ContentTemplateContainer.FindControl("fld_bcity")
            Session.Item("bcity") = anyFld.Text
            anyFld = CreateUserWizardStep2.ContentTemplateContainer.FindControl("fld_bstate")
            Session.Item("bstate") = anyFld.Text
            anyFld = CreateUserWizardStep2.ContentTemplateContainer.FindControl("fld_bzip")
            Session.Item("bzip") = anyFld.Text
            anyFld = CreateUserWizardStep2.ContentTemplateContainer.FindControl("fld_bphone")
            Session.Item("bphone") = anyFld.Text
            anyFld = CreateUserWizardStep2.ContentTemplateContainer.FindControl("fld_saddr1")
            Session.Item("saddr1") = anyFld.Text
            anyFld = CreateUserWizardStep2.ContentTemplateContainer.FindControl("fld_scity")
            Session.Item("scity") = anyFld.Text
            anyFld = CreateUserWizardStep2.ContentTemplateContainer.FindControl("fld_sstate")
            Session.Item("sstate") = anyFld.Text
            anyFld = CreateUserWizardStep2.ContentTemplateContainer.FindControl("fld_szip")
            Session.Item("szip") = anyFld.Text

            'Session.Item("bcompany") = Me.fld_bcompany.Text
        End Sub

I appreciate your help and thank you,
Michael

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...