how do I access controls from a static class?

Discussion in 'ASP .Net Building Controls' started by Grant, Dec 16, 2004.

  1. Grant

    Grant Guest

    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
    Grant, Dec 16, 2004
    #1
    1. Advertising

  2. "Grant" <> wrote in message
    news:%...
    > 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, Dec 16, 2004
    #2
    1. Advertising

  3. Grant

    Grant Guest

    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:%...
    > "Grant" <> wrote in message
    > news:%...
    >> 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, Dec 17, 2004
    #3
  4. "Grant" <> wrote in message
    news:%...
    > 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
    John Saunders, Dec 17, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SaravanaKumar
    Replies:
    6
    Views:
    9,395
    Tony Morris
    Oct 19, 2004
  2. Siemel Naran
    Replies:
    4
    Views:
    805
    Micah Cowan
    Jan 12, 2005
  3. bugbear
    Replies:
    4
    Views:
    435
    bugbear
    Aug 23, 2006
  4. Robin
    Replies:
    0
    Views:
    415
    Robin
    Jun 6, 2007
  5. Grant

    how do I access controls from a static class?

    Grant, Dec 16, 2004, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    116
    John Saunders
    Dec 17, 2004
Loading...

Share This Page