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;
}
}
Create a different class like this
You can create an instance from your code behind like below
Now you can access the DropDown index and text as
Although I provided an answer for this, Please note: