c# - Button Control is not visible to other class -


i have code gets value sql query , place value in textbox. want put class, , access main class. problem is, class wont recognize button(txtbox_ticketnum) main class. help!

 using (sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["connectionstring"].connectionstring))         {              using (sqlcommand com_retrieve = new sqlcommand("usp_selecttop1ticket", con))             {                 com_retrieve.commandtype = commandtype.storedprocedure;                 con.open();                 try                 {                     txtbox_ticketnum.text = com_retrieve.executescalar().tostring();                     messagebox.show("ticket has been saved. ticket number: " + com_retrieve.executescalar().tostring(), "ticket filed");                 }                 catch (sqlexception)                 {                     messagebox.show("the database has encountered error");                 }                 catch (exception)                 {                     messagebox.show("the server has encountered error");                 }             }         } 

it seems button (txtbox_ticketnum) private - default visual studio behaviour. can either change (set "modifiers" property of txtbox_ticketnum "public"), or add own property (better solution)

public partial class myform {   ...   public string ticketnumtext {     {       return txtbox_ticketnum.text;      }     set {       txtbox_ticketnum.text = value;      }   }    ...    myform form = new myform();    ...    con.open();    try     {       form.ticketnumtext = com_retrieve.executescalar().tostring();        ... 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -