views:

2581

answers:

4

I have a requirement where I ask user for confirmation and also display messages.

The programmers used for this were from Windows forms background. Hence have used the MsgBox in every nook and corner. Even in business logic part they have used the Messageboxes which requires Yes/No style confirmation from user.

When we tested the site from the remote machine we found that it gives error of using DefaultDesktopOnly/ServiceNotification. But when tested we found that this is totally different from what we were looking for.

Now my requirement is a confirmation box is shown from the code like Delete record" yes no and based on the reply we take the action.

This is to be done using updatepanel.

A: 

Update panel or not, you'll have to attach some javascript that would call confirm() javascript function. Based on it's result you cancel javascript default link/button behaviour...

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

Robert Koritnik
A: 

That's not really a question, but a requirement.

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

Given that your requirements are for something that works in an update panel I'd guess that wiring up javascript events manually for this isn't going to be something you are comfortable with, so I'd suggest an asp:Panel inside the UpdatePanel which has yes and no buttons, with server side events bound to them. In the UpdatePanel logic show this when you want confirmation and hide everything else, the act accordingly.

blowdart
Can you elaborate a bit more, why javascript is not appropriate?
Robert Koritnik
This subexplanation should be placed in the question as updated information instead of an answer.
Robert Koritnik
Well I'm making an assumption here. 1) They're coming from Winforms and 2) they're using the update panel. So I'd *guess* that really they're still trying to treat it like winforms, and hooking up client side javascript may be a step too much (otherwise, well, they wouldn't be using the updatepanel *grin*)
blowdart
To do this in any way (since it's not going to be trivial to them) they better learn asp.net and part themselves from winforms when developing web apps ASAP.
Robert Koritnik
But that's one of the webforms appeal, you can almost treat it like winforms. Expecting them to abandon a way that works enough to be productive is unreasonable until they have way more experience. But meh, this isn't an answer really :)
blowdart
A: 

If you want to do server-side confirms, you'll get into more complicated code generation. First of all, you'll have two views. The first one has a link/button delete but will actually be just a postback to the second view that will display confirmation form with yes/no. In this form, your yes button will actually be your delete action...

But I'd still chose a hybrid (especially if this is a grid we're talking about) of javascript and serverside (since alert() and confirm() are evil from user experience perspective):

  1. you have a linkbutton delete
  2. when user clicks on it, you replace this control with a div, that displays two linkbuttons yes/no
  3. send a postback with one of the two

Addendum

  • No linkbutton could be just dummy, to hide this confirmation and display delete again - so it means there won't be any server round trip
  • you could even create a usercontrol that mimics this sophisticated delete link behaviour to make it reusable application wide.
Robert Koritnik
+1  A: 

As you use this code in several places, I suggest you make a custom control, that takes your message and displays and Update panel with message and yes/no buttons.

Internally set some value for yes, no, cancel... so that you get something just like MessageBox.

nunespascal