A Scenario that I want to see if is possible in Web Forms RRS feed

  • Question

  • User-1771888428 posted


    Suppose we have a User Control that contains a form (a series of form controls and a save button), We design an Event in this UC that every time the save button clicked and result was successful the outside world (an outside page method) is informed and if Save is not successful an error message displays inside User Control.

    Now we want to wrap this User Control inside a UpdatePanel and place it inside a Repeater (or GridView) and connect the User Control's Event to a Page Method.

    Is it possible to change one of User Control's Contents and push Save button and Expect that, if Save was unsuccessful only relevant User Control inside its wrapping UpdatePanel is updated and an error message shows inside of it? and can we expect if Save was successful only the connected Page method is triggered and for example (inside of this method): we make the entire repeater Data Bound and then call "update" on wrapping Update panel (another outside UpdatePanel around the repeater not the ones inside repeater rows)?

    Saturday, July 14, 2018 7:19 PM

All replies

  • User475983607 posted

    Web forms allows only one HTML form so the design will not work with multiple forms.  Remove the multi-form idea and user control.  IMHO, the user control is not needed because you can simply take advantage of server control data binding which will render multiple server controls automatically.  

    I would start with the basic design and if you feel that encapsulation is needed (User Control) because the user control is used on other pages then refactor after you get the basic design working.   IMO, if the user control is not used in other pages then a user control is just over engineering.

    Sunday, July 15, 2018 3:16 PM
  • User-1771888428 posted

    I just wanted to know if this is possible or not. And I know that in web forms only one html form is allowed (see the paranthesis).<br>
    Maybe in the future when I want to use web forms I test this scenario and if it succeeds is a very good pattern for people that want evrything is encapsulated with two side communication between page and UC (using events in user controls). Encapsulate a portion and use ajax on that portion.
    Sunday, July 15, 2018 3:53 PM
  • User36583972 posted

    Hi mz1378,

    I don't fully understand what you mean according to your description. I know that you want to do something with a User Control that contains a form. And you describe the process of the scenario you want. But I don’t understand what your purpose is.

    You need to try your own thoughts and find out whether it is feasible or not.

    Best Regards,

    Yong Lu

    Wednesday, July 18, 2018 2:48 AM