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

  • SEARCH
  • Home
  • 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 8727157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:23:11+00:00 2026-06-13T08:23:11+00:00

i know i lack a base knowlage of the realtions between classes and inheritance

  • 0

i know i lack a base knowlage of the realtions between classes and inheritance

i find it hard to understand a simple thing :

a given DDl or TextBox could be accessed from code behind

int selected = DDLID.SelectedIndex ;

string userInput = TBXID.Text;

Now from a class that is placed in code behind :

public static class ControlsValue
{
   public static int UserSel = DDLID.Selected.index;
   public static string UserText = TBXID.Text;
} 

i was trying to “Arange” my code so i will be able to reuse it in some other projects

…so i have moved all global variables related to the code in that class into the class
and what i can’t do is assign variables with webControls Values

what is the way to do it ?

update

a way i could think of is via parameter

public static class ControlsValue
{
   public static void getValues(DropDownList DDLID)
   {
        public static int UserSel = DDLID.Selected.index;
   }
   public static string UserText(TextBox TBXID)
   {
      return TBXID.Text;
   }
} 
  • 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-13T08:23:12+00:00Added an answer on June 13, 2026 at 8:23 am

    Create a different class like this

    public class ControlValues{
    
        private int_dropDownIndex;
        public int DropDownIndex{
             get { return _dropDownIndex; }
             set { _dropDownIndex= value; }
        }
    
        private string _textBoxValue;
        public string TextBoxValue{
             get { return _textBoxValue; }
             set { _textBoxValue= value; }
        }
    
        public ControlValues(int dropDownIndex, string textBoxValue){
             this._dropDownIndex = dropDownIndex;
             this._textBoxValue = textBoxValue;
        }
    }
    

    You can create an instance from your code behind like below

    ControlValues cv= new ControlValues(DDLID.Selected.index, TBXID.Text);
    

    Now you can access the DropDown index and text as

    cv.DropDownIndex;  
    cv.TextBoxValue;
    

    Although I provided an answer for this, Please note:

    • Remember the stateless nature of web application and the way you are going to use this.
    • In ASP.NET, it will be inefficient to create an Instance of class to hold values of server control because those controls and their values are directly accessible from the code behind. Using this approach will be an extra overhead.
    • If you are serious about learning re-usability, I would strongly recommend you to learn basics of object oriented programming. Once you have a good grip of OOP, you will see clearly when to apply OOP principles.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question is very simple, I know it must have been asked
I've started learning C++, so I don't know in my lack of knowledge/experience why
Possible Duplicate: Anyone know a good workaround for the lack of an enum generic
Forgive me my lack of proper terminology - I don't know anything about -morphisms,
What is the right thing to do? I know that if the container is
Possible Duplicates: Anyone know a good workaround for the lack of an enum generic
Sorry for the lack of precision in the title, I didn't really know what
i know about query notifications, but they're so limited because of lack of support
I am new to AIR programming and find there is a lack of useful
Please excuse my lack of knowledge here but could someone let me know how

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.