how do I access controls from a static class?

G

Grant

Hi,

I have a page with about 40 text boxes for capturing data and need to get
the values of these text boxes to a static class for processing. I can go
through individually and add to an arraylist but there must be an easier
way..

In the aspx I can directly access these control values but I need to make
them available from the class.

Thanks,
Grant
 
J

John Saunders

Grant said:
Hi,

I have a page with about 40 text boxes for capturing data and need to get
the values of these text boxes to a static class for processing. I can go
through individually and add to an arraylist but there must be an easier
way..

In the aspx I can directly access these control values but I need to make
them available from the class.

Do you mean that you need to be able to pass these control values to a
static method of the class? Then just pass the values:

MyClass.Method(TextBox1.Text, TextBox2.Text, ...);

As a basic matter of OO programming and design, unless your static class is
meant to be intimately familiar with this particular web page, it should not
know anything about the page at all! It should just process 40 string
values. This way, for instance, you could change the web page without
changing (and retesting) the static class. For instance, do you really want
to have to change the class every time you change the name of one of the
text boxes, or move some of them inside of a Panel control?

John Saunders

P.S. If I'm off the mark, please give a bit more information about what
you're doing.
 
G

Grant

Thanks John - youre quite right, the static class shouldnt know about the
page. Ill build a string instead and pass it through for processing. Im
still relatively new to oop so sometimes the simple solution is staring me
in the face while Im looking at unecessary complications.
 
J

John Saunders

Grant said:
Thanks John - youre quite right, the static class shouldnt know about the
page. Ill build a string instead and pass it through for processing. Im
still relatively new to oop so sometimes the simple solution is staring me
in the face while Im looking at unecessary complications.

Ok, but you could make it simpler: just pass fourty separate strings.

John Saunders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top