Class getting values from code behind

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hutt
    New Member
    • Jan 2008
    • 5

    Class getting values from code behind

    Hello,
    I'm fairly new to vb.net and have a question I can't find an answer to. The site I'm working on is complex, but to keep things simple here's the basic problem.
    I have a site designed with a textbox on the default.aspx page, and I have a class in the App_Code folder (class1.vb). When the class1.vb code runs I need it to read the text from the textbox (i.e. theText = TextBox1.Text), but Visual Studio underlines TextBox1 in blue saying 'Name 'TextBox1' is not declared'. I understand that TextBox1 exists on the default.asp page and the class obviously can't see it. My question is, how can I make the class1.vb code see the textbox so I can retrieve text from it? Ultimately I will need to get all sorts of information from default.aspx when the class runs, but finding a solution to this one textbox should allow me to 'connect' to all the other controls on my page and make use of their values with the class runs. Thanks. Mark.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Whoever runs class1 from the code_behind page of default.aspx should pass the value of textbox.Text to the class/function that needs it.

    Comment

    • Hutt
      New Member
      • Jan 2008
      • 5

      #3
      Hi,
      Thanks for the reply. That clears up that I cannot access the textbox directly from the class code (which I didn't know), so thanks.

      Comment

      Working...