[Original] C # .net Add a confirmation dialog box to the button

xiaoxiao2021-03-06  40

About the pop-up dialog of C # .NET, C # determines whether or not to perform an event based on YES / NO returned by JavaScript.

I have seen a lot of research on this area.

It is found that the following code is the most simple and easy, so you have shared it.

ASPX

ASPX.CS

Protected system.Web.ui.webcontrols.button btndel;

protected system.web.ui.webcontrols.button btnprt;

Private Void Page_Load (Object Sender, System.EventArgs E)

{

IF (! ispostback)

{

}

BTNDEL.ATITRIBUTES.ADD ("onclick", "RETURN CONFIRM ('deleted?');");

Btnprt.attributes.add ("onclick", "RETURN CONFIRM ('printing?');");

}

Private void btnprt_click (object sender, system.eventargs e) {//}

Private void btndel_click (object sender, system.eventargs e) {}

转载请注明原文地址:https://www.9cbs.com/read-63342.html

New Post(0)