Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   how do I access controls from a static class? (http://www.velocityreviews.com/forums/t775033-how-do-i-access-controls-from-a-static-class.html)

Grant 12-16-2004 05:07 PM

how do I access controls from a static class?
 
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



John Saunders 12-16-2004 06:37 PM

Re: how do I access controls from a static class?
 
"Grant" <gpsnett@hotmail.com> wrote in message
news:%23lCeBH54EHA.2196@TK2MSFTNGP14.phx.gbl...
> 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.



Grant 12-17-2004 10:41 AM

Re: how do I access controls from a static class?
 
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:%23ZZZG554EHA.3760@tk2msftngp13.phx.gbl...
> "Grant" <gpsnett@hotmail.com> wrote in message
> news:%23lCeBH54EHA.2196@TK2MSFTNGP14.phx.gbl...
>> 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.
>




John Saunders 12-17-2004 03:21 PM

Re: how do I access controls from a static class?
 
"Grant" <gpsnett@hotmail.com> wrote in message
news:%234Mk2TC5EHA.1296@TK2MSFTNGP10.phx.gbl...
> 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




All times are GMT. The time now is 10:04 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.