Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.net VB.net Using the variable for an API elsewhere on the page

Hi

I am using the following VB.net code to connect to the Xero API in my web page. I also want to be use the  "myxeroapi" variable on a button click

on the page. Do I use session variables? If so what would the code look like?

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim myxeroapi As XeroCoreApi
        If IsPostBack = False Then
            'SO PAGE LOADS TWICE
            If Request.QueryString("oauth_verifier") Is Nothing Then
                'FIRST LOAD ALLOWS YOU TO AUTH IN
                myxeroapi = XeroAuthenticate(Me, False, "")
            Else
                'SECOND LOAD LET'S YOU DO SOMETHING
                myxeroapi = XeroAuthenticate(Me, True, "")
                If Not myxeroapi Is Nothing Then

                    Dim i As Integer = myxeroapi.Contacts.Find.Count 'Quick Test

                    Call oCreateInvoice(myxeroapi)

                End If
            End If
        End If
    End Sub

Open in new window

Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

first, you are calling the xero api, you got to check what is being returned from its documentation when a method is being called.

second, why you are concern about the session variable here? do you need someone to logged in before the calling or you wish to pass session variable to xero api?
Avatar of Murray Brown

ASKER

I want someone to first log in and then with other buttons etc on the page do certain things
I really just want to know how to access the myxeroapi variable in another procedure
ASKER CERTIFIED SOLUTION
Avatar of Murray Brown
Murray Brown
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial