0

Please forgive the newb question. I am very new to .NET so don't assume I've done something basic.

In ASP.NET I have a form that has a Textbox named txtOutput and a button. In the main file.aspx.vb I can call a function from the button handler and in that function I can have

txtOutput.Text = "Some Message"

with no problem. I have a bunch of functions in several other classes. For instance I have a class named AbleCommerce that does some database functions. These functions are called from my main class. In those functions, however, I have no visibility of txtOutput. All of my classes are, unfortunately, in the default namespace which I understand is not optimal but didn't seem to impact this issue.

I know this is an easy one I've just not understood properly but it has me stumped. My gut says that I probably need to pass the Textbox object to my "other class" but can't for the life of me figure how.

Any help is appreciated. Thanks!

2 Answers 2

2

The normal way is something like this:

MyTextBox.Text = MyDBClass.GetName(userID)

That is, you have classes that don't know about the UI, and a codebehind that takes values from the classes and assigns them to UI widgets.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I should be able to get there now. This is all so foreign to my linear old-school C days. But it's fun!
0

Instead of passing ASP.NET server controls to your DAL classes pass only the values they need like for example the text that has been entered in a textbox:

Dim username As String = edtUser.Text
Dim c As New AbleCommerce()
c.SomeFunction(username)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.