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

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

  1. Great sharing you have done here keep it up.

  2. Such an informative post you have shared with us,i really like your sharing.

  3. Its best way to get free clash of clans hack tool and clash of clans gems.

  4. The way that an outline is manufactured and masterminded can enormously affect the completion of the examination. In like manner concerning the people from the online paid reviews, it is their dedication to hold brisk to the marked standards set up for the association to most likely fill its need.

  5. In spite of the way that the title bank won’t approach you what the money is for, oversee yourself to not taking out an auto title progress pointlessly. With result expected in a month, these transient advances are best used for emergency costs. Take out exactly what you truly oblige so the portion is to a lesser degree a weight toward the end of the month term period.

  6. dewas says:

    Thanks a lot for sharing us about this update. Hope you will not get tired on making posts as informative as this. Clash of Clans generator

  7. On the other hand, a sensible title on the vehicle is the pivotal for such credits. This comparably helps in restoring the procedure of support of the advances. These advances are regularly speedier approve than the general credits.

  8. Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such rental atlanta

  9. India Flower says:

    This is also a very good post which I really enjoyed reading. It is not everyday that I have the possibility to see something

    like this.

  10. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. Thanks…spiderman toys

  11. payday loans says:

    Individual you understand inside corporation. Quite possibly people keep in mind convening a friend of your buddy whom worked with a financing company. Or it could be people unclearly contemplate your buddy’s sibling will a thing with real-estate

  12. What you will utilize the cash for or why you oblige it so frantically are not conveys which apply to a vehicle title credit power. There are no meddlesome solicitation which apply to the reason behind the budgetary crisis.

  13. Thanks for useful information. Custom writing services are available at 24/7.

  14. With a touch of consistent quality, you ought to be able to discover distinctive certifiable affiliations offering the sorts of snappy money credit that you require and a brief while later you can be well on your approach to manage beating your brief money needs.

  15. Laura says:

    surely, your article is worth reading!thanks a lot!we can write your essay on the regular basis without delays.All the writers are creative professionals who can compose a quality worjk according to your need, wishes and an affordable price.

  16. Get top quality essay papers from the best academic writers!

  17. essays says:

    I did all as you write and it helps. Thanks a lot for the tips.

  18. A payday credit is to a degree transient change you can use to cover usage until your next payday. You can apply online and the choice to credit you the cash is made straight away. As a rule the entire application should be possible online and the cash lent can be credited into your financial alter around the same time as you make your application.

  19. In case you oblige money then get terrifying Visas and pay them on time to make your credit. Pay more than the base hole and usage them to pay bills so you can pay what you need to pay while making your credit.

  20. happy wheels says:

    Great! Thanks for sharing the information. That is very helpful for increasing my knowledge in this field.
    happy wheels

  21. I enjoyed this article because it is not including worthless information . It’s a good occasion to express thanks for sharing article about the javascript.

  22. Greetings! I really enjoy your article, because i like the way you write and presenting your ideas. Your article about javascript is very useful and very understanding, because even I understand all. Thanks! I get to see more interesting stuff from you in future!

  23. osma says:

    Do you need a Loan?
    Are you looking for Finance?
    Are you looking for a Loan to enlarge your business?
    I think you have come to the right place.
    We offer Loans atlow interest rate.
    Interested people should please contact us on
    For immediate response to your application, Kindly
    reply to this emails below only.

    Please, do provide us with the Following information if interested.
    1) Full Name:………
    2) Gender:………
    3) Loan Amount Needed:………
    4) Loan Duration:………
    5) Country:………
    6) Home Address:………
    7) Mobile Number:………
    8)Monthly Income:…………………
    )Which site did you here about us…………………
    Thanks and Best Regards.


  24. Professional writing service is one of those services ho cares about their customers. In our company works only experts who will write for you only best essay. Visit this service with no hesitations.

  25. happy wheels says:

    Thanks for the great post.

  26. onlineitguru says:

    Testing Tools Online TrainingTesting Tools Online Training at Online IT Guru with 10+ years of real time exp. trainer, Certification level Manual, QTP and QC training with placement also

  27. payday loans says:

    With a touch of consistency, you ought to be able to discover diverse good ‘ol fashioned affiliations offering the sorts of convenient money credit that you require and a while later you can be well on your approach to manage beating your brief money needs.

  28. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own BlogEngine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it

  29. Choosing a determine fundamental places to apprehend article shells, nearly numerous confidentials symbol-screen their allow chums pertaining to handles. Lecture Lib evidence be holy to gain varieds of streamer thorn customers who’re merry beside the ramifications the street made processs too in scope they extra on putting warmhearted fresh petitions in supplement to bettering their agree qualities forward the other.

  30. Going before that of profiting the advances, you charge to satisfy a certain part to the moneylender as in advance line section. On the off superfluous that, on the off irregular that you are gainful a massive total as up front line segment, the affirmation will be normal bound and that too at correspondingly low rates.

  31. I am not an expert in JAVA or php. It is very complicted for me.

  32. starcraft says:

    Thank you so much for this article. I’ve been finding it :) It will helps me much :)

  33. mahjong says:

    I read your post and I found it amazing! thank!

  34. minecraft says:

    Wonderful blog! This is very informative site. I am totally pleased by your excellent work. Many thanks for sharing.

  35. agario says:

    In your blog I was happy to see your article, better than last time, and have made great progress, I am very pleased. I am looking forward to your article will become better and better.

  36. pacman says:

    Really impressive post. I read it whole and going to share it with my social circules. I enjoyed your article and planning to rewrite it on my own blog.

  37. web marketer says:

    You made certain nice points there. I did a search on the issue and found the majority of persons will have the same opinion with your blog.


  38. AndyCloud says:

    Perfect place to get quality essay surely! This company has many advantages like students will get qualitative written papers, the payment for their work is low and also students will be able to get 24/7 support! It sounds convinsingly, isn’t it?

  39. I think, your website is very cool. You write about news in techsphere. I will recommend your article my brother. he likes to read breaking tech news! Thanks for sharing! I am waiting for more from you! And 24/7 essay help you can find here –

  40. Informative post. Thanks for the share. keep showing your potential.

  41. Your website looks great. I have seen some interesting and valuable information in your site. You are doing a good job. I am a huge fan your site.

  42. friv online says:

    When you see the stress in work, life, friv could well be a good site to try. thanks you for sharing
    Friv Games, Friv Online,, Friv

  43. Jhone Dany says:

    The post is written in very a good manner and it contains many useful information for me. Weight loss

  44. bangalore5 says:

    Flats purchase in Bangalore |
    Flats for sale in Bangalore within your budget on, Get complete details of property specifications, amenities and location details.
    For More:

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>