Click here to Skip to main content
15,890,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public partial class Login : System.Web.UI.Page
{

 public void Button1_Click(object sender, EventArgs e)
    {

        String Strt_Address = TextBox1.Text;
        String End_Address = TextBox2.Text;

        GetTrackResults gt = new GetTrackResults();
        label1.text = gt.val1;
        label2.text = gt.val2;
        
     }

}

i have gui class(login class) so now i want to pass this string values to GetTrackResults class

C#
public class GetTrackResults
    {
       login lg = new login();
       string val1=lg.Strt_Address;
       string val2=lg.End_Address;



    }


so i creted a object to access Strt_Address and End_Address from login class



then i want to access GetTrackResults class values to print in labels....

so now i created a object in login class to do that...............

so is it okay....

or itz wrong please help me
Posted
Comments
[no name] 15-Jul-13 10:44am    
No it is not right. You do not have a property or public variable named Strt_Address or End_Address in your login class.
BiteForce 15-Jul-13 10:56am    
You gotta declare the two String variables outside the method and append the value inside the method. You cannot access local variables from another class, that's why your code is invalid.

1 solution

C#
public partial class Login : System.Web.UI.Page
{
 
 public void Button1_Click(object sender, EventArgs e)
    {
 
        String Strt_Address = TextBox1.Text;
        String End_Address = TextBox2.Text;
 
        GetTrackResults gt = new GetTrackResults();

        gt.LoginClass(Strt_Address,End_Address);
       
        
     }
 
}


C#
public class GetTrackResults
    {
       
        public void LoginClass(string Strt_Address,string End_Address)
          {
              
              string val1=Strt_Address;
              string val2=End_Address;

          }
 

 
    }
 
Share this answer
 
Comments
promod madushan 15-Jul-13 11:15am    
now i want to access val1 and val2 in login class?
how i do that?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900