c# - Including a code behind file in another .cs file in asp.net -


i writing code, , have web form called default.aspx , have code behind file default.aspx.cs , added textboxes, buttons etc. it. created .cs item called university.cs , want include default.aspx in university.cs use values in textboxes. here code default.aspx.cs:

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(*) logintable id='" + idbox.text + "' , password='" + passwordbox.text + "' , type='" + loginas.selectedvalue + "'";     sqlcommand cmd1 = new sqlcommand(query1, con);     con.open();     verify = convert.toint32(cmd1.executescalar());     con.close();     if (verify > 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;     }  } }  

i can use textboxes, buttons etc. in default.aspx.cs file not usable in university.cs file. tried write using default.aspx.cs did not work. can this?

thank you

you cannot include aspx class in .cs class. instead have try passing data through other means (eg: session, application variable, storing data in cookies, etc).


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -