简体   繁体   中英

How to handle JavaScript's confirm dialog box on GridView's PageIndexChanging event?

What I'm trying to do is when the user tries to go to a different page inside a GridView control, I want to display JavaScript's confirm dialog box. If the user clicks on OK then the page should change. If not the page should not.

What I've done at the moment is display the confirm dialog box when the GridView 's PageIndexChanging event is fired, but I can't seem to find a way to check which button was clicked on in the confirm dialog box and how to handle it.

Also, the GridView is inside an UpdatePanel and the ScriptManager.RegisterStartupScript method is being used to display the confirm dialog box.

First, you need to register your script in the scriptmanager's DataItem list. Then create the client side scripting that handles this event.

You can also do so via the following method: ScriptManager.RegisterClientScriptBlock. Here is its documentation.

You can refer to some samples .

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