Best Practices for Using ASP.NET/ Multi-User Versions for Individual Pages

It is often necessary to create a user interface for the user to go through a multi-step process. There are two common projects that you can use. One option is to make each step a separate page. Another option is to use either asp: panel or multiview control and save all the code on one asp.net page.

Whenever I use a separate approach to the page, I find that sharing data between pages is kludgy.

Whenever I use the multi-user approach, I find that the code-logic is losing cohesion. He deals with too many items at once and it becomes difficult to follow.

What criteria do you use when choosing which approach to use?

Are there other design patterns that can help with the constraints that I find in existing options?

+3
source share
3 answers

I'm not a fan of cross-linking in web forms, and I agree that your markup and code can quickly get out of hand when using MultiView.

MultiView may be a reasonable compromise, but each step is encapsulated as a separate user control. This way, you don’t have to struggle with the postback model and still get a reasonable degree of code separation.

+6
source

Not a complete solution, but you also have the Wizard option in asp.net.

0

ASP.NET WebForms - . , -.

( ), - :

void ShowPanel(Panel panel)
{
    firstPagePanel.Visible = false;
    secondPagePanel.Visible = false;
    ...
    lastPagePanel.Visible = false;

    panel.Visible = true;
}

, , . , , ShowPanel.

, , - (, , - ). , , - ShowPanel(theRightPanel);, , , , , (, ). , . , .

ViewState ( ), , , . . , . , .

, , POST .

, , ( ) . , , . .ASPX, , "" . , . , ViewState .

Page_Load . , . OnInit ( ViewState).

I am also really trying to save the code from the ASPX page itself and really use Code Behind. This is one of the things that still makes ASP.NET MVC smell for me. In addition, you can do a lot to keep your code modular and allow testability and the like. This is a little beyond your question.

0
source

Source: https://habr.com/ru/post/1755837/


All Articles