Lock form code when opening modal

Asked

Viewed 39 times

0

I have a modal boostrap that works perfectly, I call it in c# code-Behind, that way:

 ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$(function() {openModalExclusao();});", true);

And that’s the opening function:

function openModalExclusao() {
  $("#modalexclusao").modal('show');
}

But I need it to stop the execution of the code when the modal is opened, and only continue when it is closed, so it executes the code after this opening the normal modal, need equal is in a desktop project, only in ASP.NET. How can I proceed ?

Explanation Edit. I will make a password request, for example such a user will delete, but he can only delete with the administrator’s password, I need to check if the password checks, and if the password check continues the code execution:

if (senha.existesenha == 1) {
  ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$(function() {openModalExclusao();});", true);
  if (senha.confere == 1) {
    clsdb.ExecutaSQL("delete musculos where id =" + ID);
  }
}

Only before having the check return,it already continues the code and does not execute delete. Because the return of the check is in the button click of the modal.

  • Mariana, first we must understand that, js runs on the client. Knowing this, we also know that there is no way it can stop the execution of a code. What you can do is call a function that in turn triggers an ajax request to the server, and then continue your work normally...

  • @Diegosantos has some example so I can understand, and know how to include according to my needs?

  • Well, I don’t know the Behind code, but if possible, stop the execution of what you’re doing at the time you register this .js. Then, you should use the modal closure event to order a service, for example, that continues its processing. See event: https://stackoverflow.com/questions/8363802/bind-a-function-to-twitter-bootstrap-modal-close

  • Remembering that, I suggest to you without knowing your need, perhaps knowing it, we can help better

  • I will look at the example you gave me, and I will update my code to my need.

  • I updated the question, so you can understand, remembering that this modal is in the master, because I will need to call you in all Forms, so there is no redundancy in the code, I chose to put in the master.

  • You can use the closing event only on the page that needs this operation. Regardless of the modal being in the master, it will carry the DOM in the same way...

  • I didn’t understand very well @Diegosantos, I need to stop the code while the modal is not closed it should not continue.

  • I need to see the whole code of C#, but from the little I saw you can give a Return, or something like that. And then call a page in ajax that finishes what was not done. Then it is a matter of logic. We need the same font!

  • I did a function and call her when the password is checked, but how do I get this return in the codebehind? This code is in the master, I need the return in another form.

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.