Ajax-Confirmation box yes/No

Posted by Krishnasamy2008 under ASP.NET AJAX on 3/11/2011 | Points: 10 | Views : 28784 | Status : [Member] | Replies : 3
Hi Friends,

We have Yes/No confirmation box on aspx page while submiting button.If you are clicking "Yes" means it will perform insert action in database and If you are clicking "No" means it will not do any actions.

I want to do above scneario in ajax.I need some ideas and sample sites.

Thanks,
Krishna.K




Responses

Posted by: SheoNarayan on: 3/11/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Hi Krishnasamy,

Here what do you mean by Ajax? You can do this easily using JavaScript confirm function. Ajax internally uses JavaScript so anyways you will have to be dependent on JavaScript. Look at the Submit button of this page when you try to submit any response to this question. It also uses Confirm function.

Look at the source of this page, this should help you :)

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 3/11/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Check this link

http://www.codeproject.com/KB/aspnet/AJAX_Enabled_MessageBox.aspx

Thanks
Karthik
www.f5Debug.net

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: NDebata on: 4/13/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Dear,

Please call the javascript from the button on which you want confirmation like this.

OnClientClick="showConfirm(this,'Are you sure you want to go ahead?');return false;"



In Aspx page
=====================================================
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>



<script type="text/javascript" language="javascript">

var _source;
var _popup;

function showConfirm(source,message) {
this._source = source;
this._popup = $find('mdlPopup');
if(message!=undefined)
document.getElementById("confirmmsgSpan").innerHTML = message;
// find the confirm ModalPopup and show it
this._popup.show();
}

function okClick() {
// find the confirm ModalPopup and hide it
this._popup.hide();
// use the cached button as the postback source
__doPostBack(this._source.name, '');
}

function cancelClick() {
// find the confirm ModalPopup and hide it
this._popup.hide();
// clear the event source
this._source = null;
this._popup = null;
}
</script>


<Style>

.PopUpBackgroundStyle
{
background-color: #C2BFBF;
filter: alpha(opacity=50);
opacity: 0.5;
}



</Style>

<div id="DivDeleteConfirmation" runat="server" align="center" style="background-color: White;
display: none">
<table border="0" style="width: 100%" cellpadding="0" cellspacing="0">
<tr id="dragConfirmMsg" style="cursor:move;background-color: Black">
<td style="padding: 5px" align="left">
<asp:Label ID="Label2" runat="server" Text="Warning" ForeColor="White"></asp:Label>
</td>
</tr>
<tr>
<td style="padding: 10px">
<img alt="" style="vertical-align: text-bottom" src="images/warning.png" width="20"
height="20" />
<span id="confirmmsgSpan" >Confirm?</span>
</td>
</tr>
<tr>
<td align="center" style="padding: 5px">
<asp:Button ID="ButtonDeleleOkay" runat="server" Text="Yes" Width="50px" />
<asp:Button ID="ButtonDeleteCancel" runat="server" Text="No" Width="50px" />
</td>
</tr>
</table>
</div>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" CancelControlID="ButtonDeleteCancel"
TargetControlID="DivDeleteConfirmation" OkControlID="ButtonDeleleOkay" PopupControlID="DivDeleteConfirmation"
BackgroundCssClass="PopUpBackgroundStyle" OnOkScript="okClick();" DropShadow="true"
BehaviorID="mdlPopup" OnCancelScript="cancelClick();" PopupDragHandleControlID="dragConfirmMsg">
</asp:ModalPopupExtender>


Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response