views:

680

answers:

2

I want to hide the Next button on my ASP.NET Wizard control using JavaScript. Can anybody tell me if this is possible and post a javascript snippet on how to do this? Thanks!

A: 

You should be able to use the answer from question #267191 to resolve your issue.

From the link (slightly modified):

var theControl = document.getElementById("btnNext");
theControl.style.display = "none";

// to show it again:
theControl.style.display = "";
Nathan Koop
I can hide a regular button, but it's the Wizard Next button that I can't figure out. I can't seem to find the correct ID to search for.
Mike C.
hmm... tried to do this myself and sure enough can't get it to work. Sorry...
Nathan Koop
+2  A: 

2 options here...

  1. TemplatedWizardStep - that way you create the buttons yourself and can then use either the control name or a css class on the button to turn it on & off with javascript or jQuery.
  2. use StartNextButtonStyle to set a css class on your next button so you can grab the button with jQuery. Example of this one is below (I'm checking to see whether a checkbox is checked before enabling the button)

Wizard markup...

<asp:Wizard ... >
    <StartNextButtonStyle CssClass="StandardButton StartNextButton" />
    <WizardSteps>
        <asp:WizardStep runat="server" ID="AgreementStep" StepType="Start">
            <asp:CheckBox runat="server" ID="AcceptAgreement" Text="I agree to the agreement terms." TextAlign="Left" onclick='EnableNextButton();' CssClass="NormalTextBox AcceptedAgreement" />
        </asp:WizardStep>
    </WizardSteps>
</asp:Wizard>

Javascript (using jQuery) to enable/disable the next button:

<script type="text/javascript">

    function EnableNextButton() {

        var button = jQuery(".StartNextButton")
        var checkBox = jQuery(".AcceptedAgreement input:checkbox");

        if (checkBox.is(':checked'))
            button.removeAttr("disabled");
        else
            button.attr("disabled", "disabled");

    }

</script>
Scott Ivey
I am interested in your example but am a noobie at jQuery. When you are querying for the ".StartNextButton" text, does that search the CSS class names?
Mike C.
Yes, that's searching for the CSS class name. In this case, i've used 2 class names just for the selectors in jquery so that I can find the controls no matter what they are named.
Scott Ivey