Including a code behind file in another .cs file in asp.net
<p>I am writing a code, and i have a web form called Default.aspx and have a code behind file Default.aspx.cs and added some textboxes, buttons etc. to it. Now i created another .cs item called University.cs and want to include Default.aspx in University.cs to use the values in the textboxes. Here is the code for Default.aspx.cs:</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}






protected void LoginAs_SelectedIndexChanged(object sender, EventArgs e)
{

}
protected void loginButton_Click(object sender, EventArgs e)
{
    SqlConnection con = new SqlConnection();
    con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=d:\\CourseRegistration\\WebSite1\\App_Data\\Database.mdf;Integrated Security=True;User Instance=True";


    Int32 verify;
    string query1 = "Select count(*) from LoginTable where ID='" + idBox.Text + "' and Password='" + passwordBox.Text + "' and Type='" + LoginAs.SelectedValue + "'";
    SqlCommand cmd1 = new SqlCommand(query1, con);
    con.Open();
    verify = Convert.ToInt32(cmd1.ExecuteScalar());
    con.Close();
    if (verify &gt; 0)
    {
        if (LoginAs.SelectedValue == "Administrator")
            Response.Redirect("Admin.aspx");
        else if (LoginAs.SelectedValue == "Student")
            Response.Redirect("Student.aspx");
        else if (LoginAs.SelectedValue == "Instructor")
            Response.Redirect("Instructor.aspx");
    }
    else
    {
        idBox.Text = "";
        LoginError.Visible = true;
    }

}
} 
</code></pre>

<p>I can use all textboxes, buttons etc. in this Default.aspx.cs file but they are not usable in University.cs file. I tried to write <strong>using Default.aspx.cs</strong> but it did not work. What can i do about this?</p>

<p>Thank you</p>
