Home > ASP.Net, Javascript > Enable and Disable All Buttons in a GridView using JavaScript

Enable and Disable All Buttons in a GridView using JavaScript


Hi

try this Javascript function

<script type="text/javascript" language="javascript">
function disableAllButtons()
{
    var gridViewID = "<%=gvTest.ClientID %>";
    var gridView = document.getElementById(gridViewID);
    var gridViewControls = gridView.getElementsByTagName("input");

    for (i = 0; i < gridViewControls.length; i++)
    {
        // if this input type is button, disable
        if (gridViewControls[i].type == "submit")
        {
            gridViewControls[i].disabled = true;
        }
    }
}

function enableAllButtons() {
    var gridViewID = "<%=gvTest.ClientID %>";
    var gridView = document.getElementById(gridViewID);
    var gridViewControls = gridView.getElementsByTagName("input");

    for (i = 0; i < gridViewControls.length; i++) {
        // if this input type is button, disable
        if (gridViewControls[i].type == "submit")
        {
            gridViewControls[i].disabled = false;
        }
    }
}
</script>

Hope this helps

Good Luck

Advertisements
Categories: ASP.Net, Javascript
  1. Deepthi
    August 22, 2014 at 5:49 pm

    Very helpful. Thankq

  2. yasserzaid
    September 17, 2014 at 9:10 am

    @Deepthi : You are welcome hope my post helps you

  3. September 20, 2014 at 12:34 pm

    Remarκable іssueѕ here. I’m very halpy to lolοk your article.
    Thank you so much and ӏ am having a lߋok forward to contact you.
    Will you please drop mee ɑ mail?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: