Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9163635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:29:34+00:00 2026-06-17T14:29:34+00:00

When I call my function at Me.Load everything is OK, but when I trigger

  • 0

When I call my function at Me.Load everything is OK, but when I trigger my function only on the button click event all variables inside lose their set values. I just started on VB.NET so I don’t fully understand scope nature here.

Here is my code:

Public Class WorkflowForward
    Inherits FileBound.Web.FBBasePage

    ' Private decalrations
    Private cfile_id As String = ""                             ' Current files ID
    Private FBProject As Project = Nothing                      ' FileBound Project object
    Private cmd As String = ""                                  ' SQL query string
    Private FBFile As FileBound.File = Nothing                  ' Filebound file holder
    Private FBRoutes As RouteCollection = Nothing               ' FileBound route collection holder


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        ' Set SqlDataSource connection string
        FBSqlDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("FB_0371tcc").ConnectionString

        If Not Me.IsPostBack Then
            ' Set values to variables
            Page_setup() ' Here I set values to variabels
            setRoute_debug("Admin1 Test")

        End If


    End Sub

    Protected Sub sendEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles sendEmail.Click
        ' CAN I HAZ SOME TEST????
        'setRoute_debug(emailTo.SelectedValue.ToString)

        Response.Write("<script>" & Me.FBRoutes.TotalCount.ToString & "</script>")

    End Sub

    Private Sub setRoute_debug(ByVal route_to As String)

        ' IF WE HAZ SOME ITEMS FINISH THEM MUHUHAHHAHAHA
        If FBBusiness.LoggedInUser.RoutedItems.TotalCount > 0 Then
            For Each item As RoutedItem In FBBusiness.LoggedInUser.RoutedItems
                item.Complete("Completed!")
            Next
        End If




        ' DEBUG MODE #YOLO
        ' I'VE DONE IT I CAN HAZ ROUTEZ
        For Each r As Route In Me.FBRoutes
            If r.Name = route_to Then
                For Each doc As FileBound.Document In FBFile.Documents
                    doc.Route(r.ID)
                Next

            End If
        Next


    End Sub

    Private Sub Page_setup()
    ' Some code that sets values
    End Sub
End Class

When I click the button it throws this error:

Object reference not set to an instance of an object. 
Line 46:         Response.Write("<script>" & Me.FBRoutes.TotalCount.ToString & "</script>")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:29:36+00:00Added an answer on June 17, 2026 at 2:29 pm

    A button click on as asp.net page would come as a PostBack.

    Your are setting up the page only in

    If Not Me.IsPostBack
    

    This is fine for asp.net controls, cause they retain their state across PostBacks using the ViewState.

    When click a button, server receives a new request, and a new object of Page is created. Your variables are not set for this object.

    Set your page level variables on every PostBack, like this

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        ' Set SqlDataSource connection string
        FBSqlDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("FB_0371tcc").ConnectionString
    
        Page_setup() ' Here I set values to variables
    
        If Not Me.IsPostBack Then
            'Set Page level control values like TextBox values
        End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having a little difficulty getting a function to call after a .load: $(function(){ $('a.pageFetcher').click(function(){
I need to call some jQuery .load() function from flash. i Use this: import
how do I call function from another class inside a different class? Here's my
I have this code, and when I call the function with mydomain/index.php/blog everything works,
if(jQuery.browser.mozilla||jQuery.browser.opera)document.removeEventListener(DOMContentLoaded,jQuery.ready,!1),document.addEventListener(DOMContentLoaded,function(){jQuery.ready()},!1);jQuery.event.remove(window,load,jQuery.ready);jQuery.event.add(window,load,function(){jQuery.ready()}); jQuery.extend({includeStates:{},include:function(c,a,d){typeof a!=function&&!d&&(d=a,a=null);c=c.replace(\n,);jQuery.includeStates[c]=!1;var b=document.createElement(script);b.type=text/javascript;b.onload=function(){jQuery.includeStates[c]=!0;a&&a.call(b)};b.onreadystatechange=function(){this.readyState!=complete&&this.readyState!=loaded||(jQuery.includeStates[c]=!0,a&&a.call(b))};b.src=c;d?(d.constructor!=Array&&(d=[d]),setTimeout(function(){var a=!0;jQuery.each(d,function(c,b){if(!b())return a= !1});a?document.getElementsByTagName(head)[0].appendChild(b):setTimeout(arguments.callee,10)},10)):document.getElementsByTagName(head)[0].appendChild(b);return function(){return jQuery.includeStates[c]}},readyOld:jQuery.ready,ready:function(){jQuery.isReady||(imReady=!0,jQuery.each(jQuery.includeStates,function(c,a){if(!a)return imReady=!1}),imReady?jQuery.readyOld.apply(jQuery,arguments):setTimeout(arguments.callee,10))}}); jQuery.noConflict(); it's related with
How to call function using parameters in powershell with parenthesis. I have as example
How do you call function lol() from outside the $(document).ready() for example: $(document).ready(function(){ function
Is it possible to call function within the same function without specifying the function
it need a way to call function whose name is stored in a string
I'm having hard time with this simple ajax call function sendreq() { $.ajax({ dataType:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.