Search code examples
c#asp.nethtmlvisual-web-gui

ShowDialog in WebGui doesn't wait for response


What is the best way to resolve problem with ShowDialog in webgui ?

I have two Forms. MainForm i LogonForm. On page load of MainForm I want to show LogonForm (via ShowDialog) for user to connect into db. And when result is ok, rest of mainform will load.

But in webgui ShowDialog works differently as in WinForms. And after showing LogonFrom it doesn't wait for response (so the response is not ok).

How can I resolve it ?


Solution

  • Due to the nature of websites, the entire Load method must complete before anything can be sent to the client. You could, in theory, build the entire page, hide all of the content, and then show it after a successful login, but that would still require all of the information of the page to be sent to the client, and any moderately savvy user would be able to view all of that content if they wanted to.

    What you need to do is to not generate anything on the page underneath the dialog, and when the user presses the 'submit' (or whatever) button on the login popup you should send a new request to the server (rather than trying to handle it client side) in which you authenticate the user, and if appropriate, redirect them to the homepage.

    Now normally sites will just have a separate login page which sends you to a regular page. If you want to have a popup you can, but it will merely be a popup on top of a blank site which redirects to an entirely new page without a pop (on successful login).

    Web environments are inherently different from desktop applications and it requires a significant paradigm shift for you as a programmer. The solution is more than just "how do I block the form load until the popup completes" because blocking the form load means the user never sees a thing (which leads to a deadlock).