Using Yes / No Messagebox in Updatepanel AJAX

I have a requirement where I ask the user to confirm and display messages.

The programmers used for this were from the background of Windows Forms. Hence, they used MsgBox in every corner. Even in business logic, they used Messageboxes which require a Yes / No style confirmation from the user.

When we tested the site from a remote machine, we found that it gives an error when using DefaultDesktopOnly / ServiceNotification. But in testing, we found this to be completely different from what we were looking for.

Now my request is a confirmation box that is displayed from the code like Delete Record "yes no" and based on the response we accept.

This needs to be done using updatepanel.

0


a source to share


4 answers


When you use this code in multiple places, I suggest that you create your own control that accepts your message and displays and updates the bar with messages and yes / no buttons.



Internally set to yes, no, cancel ... so that you get something like MessageBox.

+1


a source


Refresh the panel or not, you will have to attach some javascript that will call the confirm()

javascript function . Based on that result, you override the default javascript link / button behavior ...



This will give you a little something to scratch your head with to start:
http://www.dotnetfunda.com/tutorials/ajax/updatepanel.aspx

0


a source


This is not a question, but a demand.

Anyway ... MessageBox is a Windows function, it is not an HTML or browser function. Now you can simulate it in one of two ways: via the javascript confirm function or using the Yes / No buttons and the corresponding event.

Given that your requirements are for something that works in the update panel, I would assume that manually connecting javascript events for this would not be convenient, so I would suggest asp: Panel inside UpdatePanel, which has yes and no, with their associated server-side events. In your UpdatePanel logic, show this when you want to confirm and hide everything else, respectively. Relevant act.

0


a source


If you want to do server side validation, you end up with more complex code generation. First of all, you will have two views. The first one has a delete link / button , but will actually just postback to the second submission which will display a confirmation form with yes / no. In this form, your yes button will actually be your delete action ...

But I still chose a hybrid (especially if this is the grid we are talking about) javascript and serveride (since alert()

both confirm()

are evil from the user's point of view):

  • you have a link to delete
  • When the user clicks on it, you replace that element with a div that displays two yes / no link buttons
  • send feedback to one of the two

Adding

  • The link to the link cannot be just dummy to hide this confirmation and show the deletion again - which means there will be no interaction with the server.
  • you can even create a usercontrol that mimics this complex delete link behavior to make it reusable.
0


a source







All Articles