Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > how do I access controls from a static class?

Reply
Thread Tools

how do I access controls from a static class?

 
 
Grant
Guest
Posts: n/a
 
      12-16-2004
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


 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      12-16-2004
"Grant" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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.


 
Reply With Quote
 
 
 
 
Grant
Guest
Posts: n/a
 
      12-17-2004
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.

"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:%(E-Mail Removed)...
> "Grant" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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.
>



 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      12-17-2004
"Grant" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Can a static member function access non-static member? dolphin C++ 3 12-05-2007 12:39 PM
How can I access non-static variables from static funcition? Neviton C++ 9 09-17-2007 10:21 PM
creating dynamic controls out of static controls Tarscher ASP .Net 9 02-13-2007 02:33 PM
Can't access static member var from static method. Why? Markus Dehmann C++ 5 07-01-2004 04:16 PM



Advertisments