Adding a Confirm Javascript PopUp to a ASP.NET GridView

The more and more I use the GridView control, the more I end up writing my own

rather then using the DataBound columns because of the additional flexiblity you get when writing your own templates.

This time I ended up writing my own TemplateField because I need to add a confirm pop up to basically a “delete” command (it didn’t really delete the database record but in fact flagged it as a different type)… but you get the idea where this might come in handy. After all you don’t want users calling saying “Yeah, I just deleted something I didn’t mean to”. Instead you want to pop up a javascript box with a “Do you really want to do this…because I am not fixing it again!”

Unfortunetly the

doesn’t offer you an


event, so this is my work around.

Here is the basic Javascript code to pop up a confirm button.


      function confirmSubmit() {

      var agree=confirm(“Do you really want to mark this prospect as in the database?”);

      if (agree)

       return true ;


       return false ;



Now in your GridView->Column Tag add a

and your onClientClick attribute. This will call your Javascript function above and display a confirm popup to your users. You also must define a onClick event that points to a function that you will need to create for the server side processing of this request.



        <asp:Button ID=”btnCustomerExist”

        text=”customer exist”



        OnClientClick=”return confirmSubmit()”

        Width=”100″ />



If the user clicks “OK” on the popup, you will need to handle the server side processing. I tend to write my own Data Access layer to handle Selects and Deletes so for me it is pretty straight forward from here, I call a function and pass in the unique id from the database.

Public Sub CustomerAlreadyExist(ByVal sender As Object, ByVal e As EventArgs)

        Dim ProspectID As Int32


        Dim btnRemoveProspect As Button = CType(sender, Button)

        Dim grdRow As GridViewRow = CType(btnRemoveProspect.Parent.Parent, GridViewRow)

        ‘Get ID

        ProspectID = grdRow.Cells(0).Text

        ‘Instant Class

        myAddProspect = New AddProspect()

        ‘Removes from Prospect Table


        ‘Refresh Gridview

        Page_Load(sender, e)

    End Sub

The End Result

Of course this won’t stop everyone from accidentally deleting users but it will stop 9/10.


A .NET, PHP, Marketing Guru authority, at least I hope I am. Reach me at

427 thoughts on “Adding a Confirm Javascript PopUp to a ASP.NET GridView

  1. Shop the stunning women partywear salwar kameez collection online at best price. We offer the best Anarkali suits, patiala suits, palazzo suits, Indian gown and much more with express shipping worldwide. Salwar Kameez USA

  2. You’ve written nice post, I am gonna bookmark this page, thanks for info. I actually appreciate your own position and I will be sure to come back here.
    Facebook Lite | Baixar Facebook | whatsapp baixar| Outlook Entrar

  3. very useful article, thank you very much and pardon me permission to share the article here admin

  4. Xnraweer says:

    The student can become self-sufficient in completing Nike Air Max 1 Mænd Sko this web and it can only be possible if he is using assignment help of professionals with years of experience.

  5. Thanks for the tip you have give. It was helpful and hope will surely be encouraging for new bee . Dubai Escorts

  6. InfraWebTech says:

    PHP specialists like team infra web tech – web design company in Jhansi has integrated programming capabilities and hands on experience.

  7. friv5000 says:

    Thank you very much for your post, So kind for you, I also hope you will make more and more excellent post and let’s more and more talk, thank you very much, dear. Friv 5000 Games is abbreviation for free flash games. Our friv games are 100% safe to play, thank you.

  8. friv4 says:

    Thank you very much for the information you shared, it’s all I’ve been looking for. Today is a beautiful day, do you want to participate in games? It will help your become more comfortable, i feel very great, please visit my website, to feel.

  9. Y8 says:

    Thank you for giving posts and articles were very amazing. I really liked as a part of the article. With a nice and interesting topics. Thanks for posting.

  10. Ronesmee says:

    I don’t know what to say, I liked your article and I hope you will have many entries or more, thanks for taking the time to show us.
    Friv Unblocked
    Y8 Unblocked
    Kizi Unblocked

  11. Emma says:

    Thank you so much for taking the time to share your experiences and talents. I hope your story will inspire others…
    Unblocked Games
    A10 Unblocked
    PUnblocked Games

  12. i found this post very helpful. thanks for sharing

  13. my Tomorrow says:

    I’m a freelance computer programmer. You can play games online my website on Friv 100 / Friv 2000 / Kizi 100
    Thanks for your great post.

  14. Y8 says:

    Thanks for your great post.I like what your blog stands for.I’m a freelance computer programmer. You can play games online my website.
    Friv 3000
    Friv 4000

  15. Graweer says:

    Information you share really right, thank you, I’ll follow you regularly to learn more 2017 Nike Air Max Lunar 1 Deluxe this url , wish you many more interesting articles!

  16. Sadiya says:

    Nice article which I need to explore more, thanks a lot for this kind article. Delighted so much to have this awesome post.

  17. soni says:

    Thanks for sharing this information with us, i always like to read these articles, cool..!

  18. Friv 100 says:

    You need entertainment. Refer to our website. hope you get the most comfortable
    Friv 5
    Kizi 2

  19. Thanks for sharing this information. I really like your blog post very much. You have really shared a informative and interesting blog post with people.

  20. may be useful for all, helpful article once and pardon me permission to share also here

  21. Soraya says:

    this is amazing progress you’ve done here, something very alike this url <

  22. Soraya says:

    this is amazing progress you’ve done here, something very alike this url

  23. At Visit Dubai Escorts check the latest escort girls in UAE coming from various countries. See Independent and Agency escorts separately for your convenience.

  24. Adnan Qhalby says:

    I really love your blog.I wanted to thank you for this great read!! cara mengatasi buah zakar bengkak dan nyeriObat Fistula Ani

  25. given article is very helpful and very useful for my admin, and pardon me permission to share articles here hopefully helped

  26. bloxorz says:

    Many thanks for sharing this very diverse opinion post where each expert has no doubt shared his best knowledge on the topic. Have more success in your journey.

  27. I hope this website you manage to be the best and be number one

  28. Sagar Singh says:

    Thanks for sharing this information, I am looking for exact same information for my Inddus site popup. I must say Thanks to an author. Straight Cut Suits

  29. KOMAL!NIFM says:

    Hi, I would like to thank you for such type of blog which is very useful and I got some informative information from it. The way you write it is good. In future please update me also because I will not lose any blog of yours.

  30. hey! nice post ,thankx to share this knowledge ,i hope next i will get more such type of information.

  31. Thanks for sharing this information with us, i always like to read these articles, cool..!

  32. Online NIFM says:

    Dear writer, I read your article and I am extremely impressed by it. Moreover, I would love to propose you to keep on updating and writing such relevant articles from time to time.
    online job oriented courses

  33. bloxorz says:

    Thank you for giving them this great knowledge, really thank you for sharing, hope you will have such great posts as this more.

  34. your blog so informative and awesome . i am regular reader of your blog. your blog increased a lot of my knowledge commodity tips

  35. I’m seeking after a similar decent work from you later on also.
    Indian Escorts in Dubai

  36. you are still in a confused state of mind then, drop us an email with your requirements and our experts will get back to you right away. Gurgaon Escorts Escorts in aerocity

  37. satkr says:

    CAll For Sage Support +1-844-857-4846 Benefits of Sage X3, Sage X3 Support Number, Sage X3 Error Support Number, Sage X3 Technical Support Phone Number, Sage X3 Phone Number

  38. satkr says:

    Call 24×7 +1 (855) 924 9509 QuickBooks Small Business Support Number.Intuit QB USA/Canada TollFree for Small Business Support Software for Tech help.QuickBooks Support Phone Number, QuickBooks POS Support Phone Number, QuickBooks Pro Support Number, QuickBooks Payroll Support Phone Number, QuickBooks Enterprise Support Phone Number, QuickBooks Desktop Support Phone Number, QuickBooks Help Desk phone Number, QuickBooks Premier Support Phone Number.

  39. a pride for me to be able to discuss on a quality website because I just learned to make an article on

  40. Yepi says:

    We are very happy to play games regularly. It’s great!

  41. escortscart says:

    Female Escorts in Ireland Later, Waziri set up a little table for the ancient “sundowner” drink. Over cocktails, we tend to toasted every alternative and marked the occasion with photos. We arrived back at the camp in darkness and prepared for dinner, which was served in a courtyard area framed by a fence of timbers ringed with hurricane lamps. It felt like “Survivor.” The 5-course dinner was superb and a nearly full moon added to the atmosphere. Afterwards, we retired to our tent and fell asleep to a symphony of bird calls, monkey shrieks, hippo grunts and a few lion roars.
    Female Escorts,High Class Call Girls,Escorts Girls,Escorts ,Escorts near me
    Visit here: Escortscart

  42. The greater part of the articles you posted impressed me.
    Indian Escorts in Dubai

  43. Great In this article, I have chosen the best WordPress comment plugins for your content

  44. Julie Srroka says:

    The Party Casino : Während wir nicht befürworten, dass jeder ein Gewinn gepflügt werden-zurück zu der Operation, wir ermutigen die Berücksichtigung eines Allokations-Programm, das berücksichtigt die “Real ” Preise für die Erhaltung der Vermögenswerte und die Maximierung ihrer Auswirkungen. Die führenden Software-Entwickler, dass Angebot live Casinospiele Playtech, Microgaming und Evolution Gaming sind und sie in der Regel für seine oder ihre Lizenznehmer, ein TV-Studio oder aus einem wahren Land betreiben gegründeten Kasino.

    Visit Here :

  45. I would like to say you,i feel so glad to come here often your study material so good and beneficial for me and also other member of your blog.

  46. casino scor says:

    Karamba Casino : One of the most effective reasons why online casino gambling in highly in-demand nowadays is because of its ability to supply a safe game play with tons of promos and bonuses like those being provided in land-based mostly casinos. But, some gamblers are still wanting for that gaming feel – the ambiance, the socialization, the live games – that’s typically encountered in traditional casinos. And in view of this truth, the business of online gambling has nevertheless unleashed another feature that will surely make your casino game additional heart pounding. And that is with the assistance of Live Dealers.
    Visit us : Karamba Casino

  47. In my whole life i can’t see great blog like this.

  48. casino scor says:

    casumo casino : A ton of folks like online casinos that offer the opportunity to try out the games for free. This is sort of an engaging feature as land primarily based casinos don’t provide this opportunity. When would you ever be ready to walk into a land based casino in the early hours of the morning to try out a number of the games at no cost so you’ll get some follow in before really spending any real money? This is never going to happen as they simply cannot meet the expense of doing this. Their cash is spent on having to obtain staff wages, building maintenance costs and taxes for running a land based mostly business. On-line casinos don’t have of these expenses so they’ll afford to splash out and offer their customers some rewards such as providing them free games to play for whatever time amount they want to.
    Visit us : Casumo Casino

  49. I am impressed by the info that you have on this site.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>