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 9205199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:53:47+00:00 2026-06-17T23:53:47+00:00

i have a small class with just a couple properties in it. here is

  • 0

i have a small class with just a couple properties in it.

here is an example:

public class clsRepLogs

public string those;
public string these;

    public void setThoseandThese
    {
    //call a stored procedure
    //get results

    this.those = something;
    this.these   = somethingElse;
    }}

from my first.aspx.cs

i call the set function:

clsRepLogs cLog - new clsRepLogs()
cLog.setThoseandThese()

so now the properties have been assigned values.

i now want to use them in another aspx.cs file to populate a form… but can’t figure out how to get to them…

i tried

clsRepLogs cLog;

lblThese.text = cLog.these;

but it’s giving me an error: “Use of unassigned local variable ‘cLog’

basically, how do i tell it to use the values i’ve already assigned to that class instance from before?

i hope i’m explaining this right, but i might be way of on what i’m doing. any help appreciated.

  • 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-17T23:53:49+00:00Added an answer on June 17, 2026 at 11:53 pm

    It sounds like you want to access the same instance of the class from multiple ASPX pages. There are multiple ways to do this; a per-user solution is to use session state.

    // page 1
    var c = new clsRepLogs();
    c.setThoseAndThese();
    Session["mykey"] = c;
    
    // page 2
    var c = (clsRepLogs)Session["mykey"];
    

    “mykey” can be any string. You may also want to check if Session contains the value before accessing it, e.g. if( Session["mykey"] != null ){ ... }

    Keep in mind:

    • Session isn’t durable; restarting the web worker process will reset all in-process sessions.
    • It’s usually not a good idea to store many large objects in Session.
    • If the data is confidential, be aware of Session fixation attacks.
    • Session can be load balanced across servers, so this solution will scale.

    For reference (alternative approaches):

    • You could use the Cache object when you don’t care about per-user isolation and want control over data expiration.
    • You could use the Application object; similar to Cache but no control over expiration.
    • You could store the object in the database and load it on each page. This is useful when you to don’t want a heavy session, and/or wish to save the data more permanently (such as a shopping cart which persists across multiple sessions).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have small class like public static class TSM { static string TokenID =
I have small class called 'Call' and I need to store these calls into
I have a small utility class : public static class SerializationUtilities { public static
We have a small wrapper class that uses ResourceManager to load string resources from
I have a small class of pre-made MySQL functions (for example a function 'insert()')
If I have small Blackberry project with just 10 or less java class files,
I have a small custom object defined as: public class TimeSeriesDefinition { public int
I have this small class looking like this: private static int field1 = -
I have a small class hierarchy where I would like to have a child
I have this small class called City that simply holds some information about a

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.