Sorry for the newb question but I am an experienced old-school programmer but I am new to a lot of the .NET ways and want to do it right. Please forgive any bad terminology or ask for clarification of I butcher it too much.
I have an ASP.NET Web Site I am creating in Visual Web Developer 2008 Express using Visual Basic as the language. It is actually a rewrite-with-mods of an existing ASP script and I’m trying to chew what I’ve bitten off. I created my page with a text box (txtOutput) on it and since the end product is very complex, and it’s generally good practice to separate like functions, I have created 4 separate classes in the App_Code section.
My main page is Sync.aspx and has a code file Sync.aspx.vb with it.
One of my code files is SyncDatabases.vb and in it I have created
Public Class SyncDB
In that class I have created some routines such as
Public Function ReadMSDB(ByVal SQLString as string) as Boolean
In this routine I want to put information in my text box txtOutput on the main form (the default – Form1).
My problem is that if I try:
Form1.txtOutput.Text = "Hello world"
or just
txtOutput.Text = "Hello world"
it says Name ‘Form1’ (or ‘txtOutput’) is not declared. I am sure I am missing something simple but have no clue what it is. I assume it’s the fact that the write command is in a file (class?) outside the file (class?) containing the page itself but I don’t know how to address it properly.
Any help is appreciated but please, don’t assume a very high base level knowledge of .Net – I’m an old fart that’s not up on these new-fangled contraptions. 🙂 Thanks!
This answer might be too simple for what you are trying to accomplish, but have you thought about using a partial class instead of 4 separate classes? A partial class would allow you to separate like functions into different files, but will allow you access to controls on your form. The other answers provide good information also, but like a lot of different things with .NET there is more then one way accomplish what you are trying to do.