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
2009-06-29 16:45:10
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.
2009-06-29 16:46:53
hmm... tried to do this myself and sure enough can't get it to work. Sorry...
Nathan Koop
2009-06-29 17:06:14
+2
A:
2 options here...
- 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.
- 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
2009-06-29 16:53:32
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.
2009-06-29 17:57:25
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
2009-06-29 18:16:48