0

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.

gariepy
  • 3,576
  • 6
  • 21
  • 34
Rusty Wizard
  • 531
  • 6
  • 20

1 Answers1

0

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.

Suresh G
  • 43
  • 6
  • The ScriptManager.ReisterClientScriptBlock is used to register it as a DataItem right? Also doesn't the ScriptManager.RegisterStartupScript register it as a DataItem? – Rusty Wizard Jul 15 '12 at 18:47
  • Hi, you can refer [this](http://stackoverflow.com/questions/2510346/asp-net-server-side-show-js-alert-box-doesnt-work-when-using-partial-post-back) link. It contains information as to how to register client side scripting inside a server code. Use OnPageIndexChanged="Your_Function()" to call the function. – Suresh G Jul 16 '12 at 13:55