简体   繁体   中英

How to use JQuery dialog as Confirm dialog in ASP.NET?

I am new to jquery and i am trying to open a dialog onclientclick of a button. The dialog is having some text and accept and decline button. On accept, it must do a server postback and and on decline should do nothing. Any pointers on this will be highly appreciated

I am trying to do the below.. but does not work

  $(document).ready(function () {

       $(function () {
           $("#SucessDialog").dialog({
               autoOpen: false,
               //width: 450,
               modal: true,
               resizable: false
           });
       });

function show_confirm()
{
       $("#SucessDialog").dialog('open');
}


<asp:Button ID="btnfinance" CssClass="btn green" runat="server" OnClientClick="show_confirm()" OnClick="btnfinance_click"  Text="Finance"  style="width:25%"></asp:Button>

The JQuery

$('#SuccessDialog').

is a selector for an element with id: SuccessDialog.

Make sure you have a

<div id="SuccessDialog">some buttons</div>

on your page somewhere.

Having pointed out the basics, the show_confirm function doesn't cancel the postback instruction. You'll need something like:

OnClientClick="JavaScript: return show_confirm;"

and return false in your show_confirm function.

I think you can use an <asp:button... inside the JQuery dialog. Just make the confirm point to the postback thats in your Original button. If you got this working, you can try to improve the code to have a more general purpose.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM