Cation: I am new to c# and all things .NET so please have mercy.
I am trying to call a method from a non local class (not in the aspx or the code behind). All examples that I find are all putting the code in the the .cs behind the .aspx page. Thats not what I am looking for.
This is what i have while testing in the code behind the .aspx, but I can't seem to figure out how to call and return the data.
How do i call this from the pageload for example?
I hope that I have been clear enough in my question.
Thanks in advance for you time.
I am trying to call a method from a non local class (not in the aspx or the code behind). All examples that I find are all putting the code in the the .cs behind the .aspx page. Thats not what I am looking for.
This is what i have while testing in the code behind the .aspx, but I can't seem to figure out how to call and return the data.
Code:
class UserControlPresenter
{
public void GetAuthorizedUsers()
{
string selectSQL = "SELECT [user_id], [user_lname] + ', ' + [user_fname] AS userName FROM [user] ORDER BY [user].[user_fname];";
SqlCommand cmd = new SqlCommand(selectSQL, new SqlConnection(ConfigurationManager.AppSettings["SQLConnectionString"]));
cmd.Connection.Open();
SqlDataReader ddlValues;
ddlValues = cmd.ExecuteReader();
lst_Users is the DropDownControl from the .aspx page which obviously wont work in this remote method but I thought that I should show you what I had working in the .aspx.
lst_Users.DataSource = ddlValues;
lst_Users.DataValueField = "user_id";
lst_Users.DataTextField = "userName";
lst_Users.DataBind();
cmd.Connection.Close();
cmd.Connection.Dispose();
}
}
How do i call this from the pageload for example?
I hope that I have been clear enough in my question.
Thanks in advance for you time.