Disable Button while processing request in VB.Net

Posted on 2004-11-03
Last Modified: 2010-05-18

I'm trying to simply disable an ASP:Button while processing database requests in VB.Net. Since you need a postback to have your btnReset.Enabled = False to take into effect, I'm thinking the only way is to do it in JavaScript. But when doing it in JavaScript and doing a btnReset.Attributes.Add("onClick", "...javascript..."), it does disable the button but nothing else executes after that. How can I achieve what I'm trying to do in the simplest form?

Thanks for your help,
Question by:gometang
    LVL 15

    Expert Comment

    btnReset.Attributes.Add("onClick", "this.disabled = true; document.forms[0].submit();")

    Author Comment

    I don't think that's going to work. I have my logic in the btnClick event:

    Private Sub btnResetEnrollment_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnResetEnrollment.Click

    If I do a regular form submit (post back), it will just go the Page_Load event and not into the method above, which is what I want. Basically, I want to achieve the following based on the user clicking the button:

    1. Disable button
    2. Execute everything in the btnResetEnrollment_Click event (BTW, I'm aware that I just put btnReset in the example above as it just served as an example)

    LVL 20

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now