Passing web form controls from a page to an external class

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy B

    Passing web form controls from a page to an external class

    I have a web form that has controls to be modified on it. The class that
    will modify the controls is not contained inside the page code. How would I
    best pass the controls to the external class?



  • Patrice

    #2
    Re: Passing web form controls from a page to an external class

    As a parameter (MyInstance.MyM ethod MyControl) ?

    You may want to elaborate a bit as you likely have a particular problem ?
    Your code is in App_Code ???

    --
    Patrice

    "Andy B" <a_borka@sbcglo bal.neta écrit dans le message de groupe de
    discussion : u1dqWZKxIHA.437 6@TK2MSFTNGP06. phx.gbl...
    I have a web form that has controls to be modified on it. The class that
    will modify the controls is not contained inside the page code. How would
    I best pass the controls to the external class?
    >
    >
    >

    Comment

    • Andy B

      #3
      Re: Passing web form controls from a page to an external class

      Hi...

      I dont use app_code since I am using web application projects instead of
      website projects. This is what is going on. I have a page called Create.aspx
      that has some controls on it (3 labels, 2 textboxes, 2
      requiredFieldVa lidators , 2 textboxcounters and a linkButton). I have to
      change state of the controls (1 label, 2 textboxes, 2
      requiredFieldVa lidators, 2 textboxCounters and linkButton). The state of
      these controls listed above depends on the CommandName of the link button.
      Along with all of this control state switching, I need to create and fill
      dataset with different values from the 2 textboxes. To reduce code clutter,
      I was told that I should put the code that changes the state of these
      controls outside of the page itself. Any advice on what way to go from here?


      "Patrice" <http://www.chez.com/scribe/wrote in message
      news:D2C5654F-968A-4447-B802-24479BF69D25@mi crosoft.com...
      As a parameter (MyInstance.MyM ethod MyControl) ?
      >
      You may want to elaborate a bit as you likely have a particular problem ?
      Your code is in App_Code ???
      >
      --
      Patrice
      >
      "Andy B" <a_borka@sbcglo bal.neta écrit dans le message de groupe de
      discussion : u1dqWZKxIHA.437 6@TK2MSFTNGP06. phx.gbl...
      >I have a web form that has controls to be modified on it. The class that
      >will modify the controls is not contained inside the page code. How would
      >I best pass the controls to the external class?
      >>
      >>
      >>
      >

      Comment

      • Patrice

        #4
        Re: Passing web form controls from a page to an external class

        Your best bet would be likely to discuss with the architect that told you to
        do so...

        In this case you may want to turn this set of controls into a user or custom
        controls (googling for this should return tons of links) so that you can
        reuse the same ui in other pages...

        More generally either :
        - the routine is specific to a page and you can then keep it inside a page
        - or it could be called from another page and then you could put this in
        your own utilities class so that you can call this from anywhere

        Also you don't necessarily have to pass the whole control. You could just
        call a function that would provide the single state (visible, enabled or
        whatever else) that should be applied to this control. This is only if you
        do something very specific on a particular control type and that you could
        call this from multiple pages that you could put this inside your own
        utility class...

        In all cases, you'll pass data back and forth using arguements (or perhaps
        using properties if you are using a class that can perform long term
        operations on the same data)

        --
        Patrice


        "Andy B" <a_borka@sbcglo bal.neta écrit dans le message de groupe de
        discussion : uwygh2MxIHA.599 6@TK2MSFTNGP04. phx.gbl...
        Hi...
        >
        I dont use app_code since I am using web application projects instead of
        website projects. This is what is going on. I have a page called
        Create.aspx that has some controls on it (3 labels, 2 textboxes, 2
        requiredFieldVa lidators , 2 textboxcounters and a linkButton). I have to
        change state of the controls (1 label, 2 textboxes, 2
        requiredFieldVa lidators, 2 textboxCounters and linkButton). The state of
        these controls listed above depends on the CommandName of the link button.
        Along with all of this control state switching, I need to create and fill
        dataset with different values from the 2 textboxes. To reduce code
        clutter, I was told that I should put the code that changes the state of
        these controls outside of the page itself. Any advice on what way to go
        from here?
        >
        >
        "Patrice" <http://www.chez.com/scribe/wrote in message
        news:D2C5654F-968A-4447-B802-24479BF69D25@mi crosoft.com...
        >As a parameter (MyInstance.MyM ethod MyControl) ?
        >>
        >You may want to elaborate a bit as you likely have a particular problem ?
        >Your code is in App_Code ???
        >>
        >--
        >Patrice
        >>
        >"Andy B" <a_borka@sbcglo bal.neta écrit dans le message de groupe de
        >discussion : u1dqWZKxIHA.437 6@TK2MSFTNGP06. phx.gbl...
        >>I have a web form that has controls to be modified on it. The class that
        >>will modify the controls is not contained inside the page code. How
        >>would I best pass the controls to the external class?
        >>>
        >>>
        >>>
        >>
        >
        >

        Comment

        Working...